wyrd33
05-04-2006, 07:45 PM
If I do a string.replace("<", "<"); it replaces the first instance of < in the string. I want all instances of < replaced, so I did string.replace("/</g", "<");. Unfortunately it now replaces none at all.
What's wrong with string.replace("/</g", "<");?
Beagle
05-04-2006, 07:52 PM
string.replace(/</g, "<");
you're using a string instead of a regular expression. Take the quotes out as in the above example
wyrd33
05-04-2006, 07:59 PM
string.replace(/</g, "<");
you're using a string instead of a regular expression. Take the quotes out as in the above example
Gah.. "duh" lol. Thanks. I guess my mind was stuck in PHP mode. :P
I should have used rather unicode escapes to be able to safely handle the string within javascript:
string.replace(/</g,'\u003C');