Category talk:String

Strings containing a dash or a colon, and presumably other punctuation, can present an obstacle when using a string function such as replace.

One way to resolve this is to replace or remove the offending punctuation before attempting the string replace.

example:

TextBuffer _tb1 = new TextBuffer; TextBuffer _tb2 = new TextBuffer; str origvalue = "colon is here: abc"; str newvalue = "colon is gone";

//remove the colons _tb1.setText(origvalue); _tb2.setText(newvalue); _tb1.replace("\\:",""); _tb2.replace("\\:","");

//set the strings to the resulting values origvalue = _tb1.getText; newvalue = _tb2.getText;

//replace the first string with the second string _tb1.replace(origvalue, newvalue);

print "resulting string is " + _tb1.getText; pause;