I have recently come across an interesting question on strings. Suppose you are given following:
Input string1: "this is a test string"
Input string2: "tist"
Output string: "t stri"
So, given above, how can I approach towards finding smallest substring of string1 that contains all the characters from string 2?
...
how to remove the \n, \t and spaces between the strings in java?
...
what is difference of below operators for spaces?
\t, \n, \x0B, \f and \r.
...
Hi!
I am using an XMLHttpRequest to POST a JSON string to PHP. The JSON object is created in JavaScript and using the JSON2.js from json.org to create an JSON string representing the object.
JSON.stringify(object);
Whenever the object contains a string which has a special character in it, e.g. é, JavaScript does not give any error but...
how to get value without <br/> tag using regex n java?
my String is:
<Div>
West Newton, MA 02465
<br/>USA
</Div>
output should be like:
West Newton, MA 02465
USA
my pattern is like:
Pattern p8 = Pattern
.compile("<div class=\"leftLabel\">Nickname</div>\\s+<div class=\"rightContent\">([^<]*)</div>");
Matcher ...
So I've a string:
string x = "DR\nDC\nDD";
I want to get each line in a separated variable like this:
string y1 = "DR";
String y2 = "DC";
String y3 = "DD";
How can I do that?.
...
Here is a snap of my database.
Both col1 and col2 are declared as int.
My ComputedColumn currently adds the Columns 1 and 2, as follows...
col1 col2 ComputedColumn
1 2 3
4 1 5
Instead of this, my ComputedColumn should join the columns 1 and 2 (includimg the '-' character in the middle) as follows...
col1 col2 C...
Example:
Suppose in the following example I want to match strings that do not contain the word "NOOOT".
Example A: This shirt is NOOOT black.
Example B: This shirt is black.
I want something a little bit like the like the non-matching character class (e.g. [^abc]), but for whole strings:
.*?(^NOOOT).*?
Does such a creature exist?
...
I have trouble with changing round bracket tag in Javascript. I try to do this:
var K = 1;
var Text = "This a value for letter K: {ValueOfLetterK}";
Text = Text.replace("{ValueOfLetterK}", K);
and after that I get:
Text = "This a value for letter K: {ValueOfLetterK}"
What can be done to make this work? When I remove round brackets ...
How do I find:
string str="(120)(1500)x";
How to find out in the event that the string contains:
string str1="()()X";
I then have to print:
console.writeline("str1 doesnt contain a numerical");
...
hi, i want only the first word of a variable.. example input:
<?php $myvalue = 'Test me more'; ?>
the output should only "Test", the first word of the input.. how can i do this?
...
Hi,
In Java is there a way to extract the value of an unknown subset of a string via a regex. For example in the following string "hello world 1234" I want to be able to extract the value 1234 via the regex [0-9]*. Is there a way to do this?
...
So I have a string "SmartUserWantsToLive" I want to generate from it or any such string with capital letters strings like "Smart User Wants To Live". How do I do this?
...
Here is the situation:
I am making a small prog to parse server log files.
I tested it with a log file with several thousand requests (between 10000 - 20000 don't know exactly)
What i have to do is to load the log text files into memory so that i can query them.
This is taking the most resources.
The methods that take the most cpu t...
I am trying to find a regular expression within a line of a .csv file, so I can eventually save all the matches to another file, and lose all the other junk.
So a line in my file might look like:
MachineName,User,IP,VariableData,Location
The VariableData is what I want to match, and if there's a match, print the line. I am using a patt...
There are many similar questions, but apparently no perfect match, that's why I'm asking.
I'd like to split a random string (e.g. 123xx456yy789) by a list of string delimiters (e.g. xx, yy) and include the delimiters in the result (here: 123, xx, 456, yy, 789).
Good performance is a nice bonus. Regex should be avoided, if possible.
Up...
I'm hoping for a concise way to perform the following transformation. I want to transform song lyrics. The input will look something like this:
Verse 1 lyrics line 1
Verse 1 lyrics line 2
Verse 1 lyrics line 3
Verse 1 lyrics line 4
Verse 2 lyrics line 1
Verse 2 lyrics line 2
Verse 2 lyrics line 3
Verse 2 lyrics line 4
And I want to...
Hi,
I am trying to write a regex to match pairs of cards (AA, KK, QQ ... 22) and I have the regex ([AKQJT2-9])\1. The problem I have is that this regex will match AA as well as AAbc etc. Is there a way to write the regex such that I can specify I want to match ([AKQJT2-9])\1 and only that (i.e. no more characters after).
Thanks
...
Hi,
I want to match against Strings such as AhKs & AdKs (i.e. two cards Ah = Ace of Hearts). I want to match two off-suit cards with a regex, what I currently have is "^[AKQJT2-9][hscd]{2}$", but this could match hands such as AhKh (suited) and AhAh. Is there a way to possibly use backreferences to say the second [hscd] cannot be the sa...
Which is the best way to "sanitize" content? An example...
Example - Before sanitize:
Morbi mollis ante vitae massa suscipit a tempus est pellentesque. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Nulla mattis iaculis consectetur.
Morbi mollis ante vitae est pellentesque. Pellentesque ha...