str.replace(/\([\w\s]*\)/gi, "");
any suggestions ?
Looks like it should, although you won't be stripping digits. What's
the issue?
It's not working...
sample string is :
"Electronic media (DVDs, CDs), Paper (books, photos), Textiles (clothes, linens), Furniture"
should return:
"Electronic media, Paper, Textiles, Furniture"
It's the commas in the parens.
str.replace(/\([^\)]*\)/gi, '');
\([^)]*\)
--
My personal UDP list: 127.0.0.1, 4ax.com, buzzardnews.com, googlegroups.com,
heapnode.com, localhost, ntli.net, teranews.com, vif.com, x-privat.org
Posting correct untested answers requires real intelligence; one rarely
finds that in the witterings of anonymous gmail users.
The test string subsequently provided contains parenthesised commas; the
RegExp does not accommodate that.
This works on the test data : str.replace(/\([^)]*\)/g, "");
-> Electronic media , Paper , Textiles , Furniture
And str.replace(/\s*\([^)]*\)/g, "");
-> Electronic media, Paper, Textiles, Furniture
--
(c) John Stockton, nr London UK. ???@merlyn.demon.co.uk Turnpike v6.05 MIME.
Web <URL:http://www.merlyn.demon.co.uk/> - FAQish topics, acronyms, & links.
Check boilerplate spelling -- error is a public sign of incompetence.
Never fully trust an article from a poster who gives no full real name.