473,322 Members | 1,566 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,322 software developers and data experts.

replacement expression

need some help with a str.replace expression to strip all content between any occurrence of parentheses and also remove parentheses
....

str.replace(/\([\w\s]*\)/gi, "");

any suggestions ?

Jun 27 '08 #1
5 909
On May 8, 2:06*pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
comwrote:
need some help with a str.replace expression to strip all content between any occurrence of parentheses and also remove parentheses
...

str.replace(/\([\w\s]*\)/gi, "");

any suggestions ?
Looks like it should, although you won't be stripping digits. What's
the issue?
Jun 27 '08 #2

"apatheticagnostic" <ap***************@gmail.comwrote in message
news:3f**********************************@m36g2000 hse.googlegroups.com...
On May 8, 2:06 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
comwrote:
need some help with a str.replace expression to strip all content between any occurrence of parentheses and also remove
parentheses
...

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"
Jun 27 '08 #3
On May 8, 3:23*pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
comwrote:
"apatheticagnostic" <apatheticagnos...@gmail.comwrote in message

news:3f**********************************@m36g2000 hse.googlegroups.com...
On May 8, 2:06 pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot

comwrote:
need some help with a str.replace expression to strip all content between any occurrence of parentheses and also remove
parentheses
...
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, '');
Jun 27 '08 #4
In article <ZIWdnV4pe96T3L7VnZ2dnUVZ_jydnZ2d@palinacquisition >,
"Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot comwrote:
need some help with a str.replace expression to strip all content between any
occurrence of parentheses and also remove parentheses
...

str.replace(/\([\w\s]*\)/gi, "");

any suggestions ?
\([^)]*\)

--
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
Jun 27 '08 #5
In comp.lang.javascript message <3fc20dfe-e95f-4272-b5f1-4108644186b5@m3
6g2000hse.googlegroups.com>, Thu, 8 May 2008 11:40:40, apatheticagnostic
<ap***************@gmail.composted:
>On May 8, 2:06*pm, "Jon Paal [MSMD]" <Jon nospam Paal @ everywhere dot
comwrote:
>need some help with a str.replace expression to strip all content between any occurrence of parentheses and also remove parentheses
...

str.replace(/\([\w\s]*\)/gi, "");

any suggestions ?

Looks like it should, although you won't be stripping digits. What's
the issue?
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.
Jun 27 '08 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Dan | last post by:
Hello, I'd like to be able to take a formatted string and determine the replacement dictionary necessary to do string interpolation with it. For example: >>> str = 'his name was %(name)s and...
53
by: Kerberos | last post by:
I followed Dan Cederholm's image replacement tutorial, to replace a header tag by a logo. The h1 is clickable if no CSS is applied but it I replace it by the logo, the area isn't clickable anymore...
3
by: Vibha Tripathi | last post by:
Hi Folks, I put a Regular Expression question on this list a couple days ago. I would like to rephrase my question as below: In the Python re.sub(regex, replacement, subject)...
4
by: andrewflanders | last post by:
I have an associative array of keys and values. I want to search a string for the existance of keys and replace them with the values in the array. The problem is that some of the keys resemble...
30
by: Mike Meyer | last post by:
I know, lambda bashing (and defending) in the group is one of the most popular ways to avoid writing code. However, while staring at some Oz code, I noticed a feature that would seem to make both...
18
by: talin at acm dot org | last post by:
I've been reading about how "lambda" is going away in Python 3000 (or at least, that's the stated intent), and while I agree for the most part with the reasoning, at the same time I'd be sad to see...
2
by: brian | last post by:
Hi, before coming to .NET, I utilized regular expressions mostly in JScript / JavaScript and also in my favorite text editor: TextPad (www.textpad.com) I don't know about JScript/JavaScript, but...
32
by: chris.fairles | last post by:
Just want an opinion. I have an algorithm that needs to run as fast as possible, in fact. Its already too slow. I've done as much algorithmic changes as I can to reduce the amount of code, so now...
4
by: Phil Sandler | last post by:
Hello, What is the fastest/most efficient way of doing string replacement in csharp/.net? An example would be: "Hello, my name is {FirstName}, and I live in the town of {City} with my wife...
5
by: padmaneha | last post by:
How to omit replacement in somepart of text using regular expression? For ex: If i want to replace mumbai with mumbai/aaa.com but if i have an anchor tag <a...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.