I want to replace and insert escape character sequences with their escape character values, also taking into account that '\' nullifies the escape character.
For example
"This is a \n test. Here is a \\n which represents a newline"
What is the easiest way to achieve this in Ruby?
...
I have a combobox that has the entries of a full name, eg: John Smith, Mark Tall, etc.
I have written the following:
string FullName = StudentSelectStudentComboBox.Text;
This gets "John Smith" as the string 'FullName'. Is it possible to break down 'FullName' string into 2 strings; FirstName and LastName?
...
Hello,
Part of an app I am working on includes a log file viewer, with a find text function, which calls a pattern matcher on JTextField#getText(), like so:
Matcher m = somePattern.matcher(textField.getText());
m.find(startPosn);
System.out.println("startPosn: " + m.start());
System.out.println("endPosn: " + m.end());
where textField...
I'm looking for the best reliable way to return the first and last name of a person given the full name, so far the best I could think of is the following regular expression:
$name = preg_replace('~\b(\p{L}+)\b.+\b(\p{L}+)\b~i', '$1 $2', $name);
The expected output should be something like this:
William -> William // Regex Fails
Will...
I am beginning to write a translator program which will translate a string of text found on a file using parallel arrays. The language to translate is pig Latin. I created a text file to use as a pig latin to English dictionary. I didn't want to use any two dimension arrays; I want to keep the arrays in one dimension.
Basically I want to...
I have a string like
A150[ff;1];A160;A100;D10;B10'
in which I want to extract A150, D10, B10
In between these valid string, i can have any characters. The one part that is consistent is the semicolumn between each legitimate strings.
Again the junk character that I am trying to remove itself can contain the semi column
...
I have a slight problem with a path:
"D:\\Music\\DJ Ti%C3%ABsto\\Tiesto\\Adagio For Strings (Spirit of London).mp3"
"D:\\Music\\Dj Tiësto\\Tiesto\\Adagio For Strings (Spirit of London).mp3"
Currently, when it sends that path to my Audio Library, it cannot open the path. (the reason for it crashing is trying to assign a -1 to a trackba...
string a = "asdf xyz 123 xx 3212";
string seperator = "z 1";
need to write a script that returns 0 if left of the seperator has more characters, otherwise return 1
in this case it should return 1
...
I know that strcat (dest, src) appends src to dest, and returns dest.
Now, if I want to append dest, to src. i.e. insert string "src" before dest, is their any way to do that?
I tried using strcat something like
dest = strcat (dest, src);
but could not make it work.
PS: I am trying out a few options. As this this solution is needed ...
I am looking for an existign path truncation algorithm (similar to what the Win32 static control does with SS_PATHELLIPSIS) for a set of paths that should focus on the distinct elements.
For example, if my paths are like this:
Unit with X/Test 3V/
Unit with X/Test 4V/
Unit with X/Test 5V/
Unit without X/Test 3V/
Unit without X/Tes...
I was trying to speed up a certain routine in an application, and my profiler, AQTime, identified one method in particular as a bottleneck. The method has been with us for years, and is part of a "misc"-unit:
function cwLeftPad(aString:string; aCharCount:integer; aChar:char): string;
var
i,vLength:integer;
begin
Result := aString;
...
What is the best way to interleave a java String with a given character sequence. The interleave interval should be changeable.
Example:
String s = " .... 0000000000000 ..."; // length random
String b = interleave(s, 3, "-");
Result:
... 000-000-000-000-000 ...
another example:
String s = " .... we all we all we all ...";
String ...
Hi, I'm working with cocoa on the iPhone and I'm looking for some method like:
NSString *s = @"Hello";
[s isStringStartsWithUpperCaseCharacter]
-(BOOL) isStringStartsWithUpperCaseCharacter;
The first letter of the string may be non ASCII letter like: Á, Ç, Ê...
Is there some method which can helps me?
I saw in the documentation that...
I have a string pointer like below,
char *str = "This is cool stuff";
Now, I've references to this string pointer like below,
char* start = str + 1;
char* end = str + 6;
So, start and end are pointing to different locations of *str. How can I copy the string chars falls between start and end into a new string pointer. Any existing ...
Python 2.6 (trunk:66714:66715M, Oct 1 2008, 18:36:04)
[GCC 4.0.1 (Apple Computer, Inc. build 5370)] on darwin
Type "help", "copyright", "credits" or "license" for more information.
>>> path = "/Volumes/Users"
>>> path.lstrip('/Volume')
's/Users'
>>> path.lstrip('/Volumes')
'Users'
>>>
I am expecting output of path.lstrip('/Volumes') ...
Essentially, I need to parse the response string of the CHAT CREATE command with AppleScript to get the chatid. The response looks like:
CHAT #my.username/$123abc456blah STATUS MULTICHAT
I tried
set chatid to item 2 of response
but that returns 'H' -- I also tried
set chatid to word 2 of response
but that returns 'my'. I ima...
Hi,
I'm trying to initialize string with iterators and something like this works:
ifstream fin("tmp.txt");
istream_iterator<char> in_i(fin), eos;
//here eos is 1 over the end
string s(in_i, eos);
but this doesn't:
ifstream fin("tmp.txt");
istream_iterator<char> in_i(fin), eos(fin);
/* here eos is at this same position as in_i*/
...
The string is setup like so:
href="PART I WANT TO EXTRACT">[link]
...
Hi,
I have started to do the questions on project euler regarding lists of names which need to be replaced with their corresponding position in the alphabet. In question 22 I need to replace, the letters with numbers:
names = ["MARY","PATRICIA","LINDA"....
replace = ??????
char2num a = map replace a
score (a,b) = a * (sum $ map char2num...
Hi,
I have a column called THE_VALUE in a table TABLE_A, that holds data similar to the following, i.e a few sample rows might be:
tom:harry, sally, jeff
state(vic,nsw), england, qwerty(aaa,bbb, cccc):qaz
What I need to do to update this column using Oracle 10g sql and replace all commas, except the ones within the brackets with a co...