[thelist] regex: replacing bracket characters

Plunkett, Matt MPlunkett at MSA.com
Wed Dec 10 08:45:58 CST 2003



-----Original Message-----
> From: Tom Dell'Aringa

> I want to replace the ( and ) characters in a string (for example,
> strip them out of the area code in a phone number). I can't seem to
> figure out the pattern for these characters.

> objRegExp = /()/g;
> objRegExp = /\(\)/g;

Both of these regexps try to match (), not ( or ).   Try 

/[\(\)]/

Brackets mean to match any character inside them.


More information about the thelist mailing list