[英]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. 我正在寻找一个JavaScript正则表达式,它将以字符串形式(用于列出电子邮件地址的Outlook格式)删除所有用引号引起来的内容(也包括qoutes)。 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"BillsRestauraunt@comcast.net,"Rob&Julie"robjules@ntelos.net,"Foo&Bar"foobar@cstone.net
假设没有嵌套的引号:
mystring.replace(/"[^"]*"/g, '')
试试这个正则表达式:
/(?:"(?:[^"\\]+|\\(?:\\\\)*.)*"|'(?:[^'\\]+|\\(?:\\\\)*.)*')/g
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);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.