开发者

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... Th开发者_如何转开发e 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. 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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜