Agile Noob
Agile Noob

Reputation: 2335

Javascript regular expression to strip out content between double quotes

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]

Upvotes: 2

Views: 6855

Answers (3)

dkretz
dkretz

Reputation: 37645

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\)\.\,;]?)/g);

Upvotes: 0

Gumbo
Gumbo

Reputation: 655229

Try this regular expression:

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

Upvotes: 2

ʞɔıu
ʞɔıu

Reputation: 48406

Assuming no nested quotes:

mystring.replace(/"[^"]*"/g, '')

Upvotes: 5

Related Questions