[Javascript] OT: RegExp

Shawn Milo milo at linuxmail.org
Wed May 12 13:31:01 CDT 2004


<snip>
> >         someQuery = someQuery.replace(/\([^)]*\)/g, '');
> >
> >
> >
> >explanation of regex:
> >
> >find a ( followed by anything that is not a ) for any number of characters (including zero),
> >followed by a ).  Replace the entire thing with an empty string.
> >
> >The '(' and ')' are escaped '\(' and '\)'  because parenthesis have 
> >meaning in regexes.
<snip>

You're welcome.

Also, the 'g' stands for 'global'.  That means to replace multiple
occurrances, if they exist.  Another commonly used switch is 'i', 
for 'case insensitive'.  



More information about the Javascript mailing list