views:

1681

answers:

3

I'm looking for a javascript regex that will remove all content wrapped in quotes(and the qoutes too), in a string that is the outlook format for listing email addresses. Take a look at the sample below, I am a regex tard and really need some help with this one, any help/resources would be appreciated!

"Bill'sRestauraunt"[email protected],"Rob&Julie"[email protected],"Foo&Bar"[email protected]
A: 

Here's a regex I use to find and decompose the quoted strings within a paragraph. It also isolates several attendant tokens, especially adjacent whitespace. You can string together whichever parts you want.

var re = new RegExp(/([^\s(]?)"(\s*)([^\]*?(\.[^\]*))(\s)("|\n\n)([^\s).\,;]?)/gms);

le dorfier
+4  A: 

Assuming no nested quotes:

mystring.replace(/"[^"]*"/g, '')
ʞɔıu
+1  A: 

Try this regular expression:

/(?:"(?:[^"\\]+|\\(?:\\\\)*.)*"|'(?:[^'\\]+|\\(?:\\\\)*.)*')/g
Gumbo