Note that the following trace statement will display the modified value in the console, but will NOT change the value in the lParagraph variable!!
var lParagraph:String = "This is my ::Placeholder::"
var myPattern:RegExp = /::Placeholder::/;
trace(lParagraph.replace(myPattern, "replaced text")); // shows "This is my replaced text"
trace(lParagraph);
// still shows "This is my ::Placeholder::" !!!! - which is quite confusing.
If you want to have lParagraph changed, you must do so explicitely:
lParagraph = lParagraph.replace(myPattern, "replaced text"));
19. August 2009
String.replace - be careful !
Abonnieren
Posts (Atom)