简体   繁体   English

正则表达式匹配引号外的文本等

[英]Regular Expression to match text outside quotes etc

"([\"'])(?:\\\\?+.)*?\\1"

I came up to this regexp to match all quoted strings.. It seems to work great... The problem is how to match the text that isnt inside quotes.. The inverse -negative somehow... 我来到这个正则表达式匹配所有引用的字符串..它似乎工作得很好...问题是如何匹配不在引号内的文本..逆 - 负某种方式...

I read the documentation and 我阅读了文档和

(?!(([\"'])(?:\\\\?+.)*?\\1))

doesnt work 不起作用

Hmm If the first regular experssion works, I would use it to remove all quoted strings from the input string. 嗯如果第一个常规experssion工作,我会用它从输入字符串中删除所有引用的字符串。 Then, all you will be left with is the text that was outside quoted strings. 然后,您将留下的所有内容都是引用字符串之外的文本。 With certain types of patterns, I find this approach much easier and simpler. 对于某些类型的模式,我发现这种方法更容易和更简单。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM