Click to See Complete Forum and Search --> : Re: replace several "( OR )" in strings


mannaerts_davy
01-09-2003, 02:36 AM
Dear,

I have to replace several "( OR )" in strings from the user.
these strings are used to generate a html page and if I don't replace them, the html page gives errors because it thinks that the ( or ) is a part of the syntax.

I used string.replace() but it seems to work for every symbol or letter except for these.
like this : string.replace("(", "")
substitude ( by ""


The problem I have is that it seems to work perfect with internet explorer but netscape gives errors with this same construct.

jeffmott
01-09-2003, 03:24 AM
Parentheses are metacharacters (reserved for special use) in regular expressions. You have to dereference it with a backslash.

string.replace(/\(/, "");

I'm also a little curious how "( OR )" gets interpreted as part of an HTML page.