除了前面没有反斜杠的双引号外,匹配任何东西的正则表达式是什么? [英] What's the regex to match anything except a double quote not preceded by a backslash?
本文介绍了除了前面没有反斜杠的双引号外,匹配任何东西的正则表达式是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
换句话说,我有一个字符串:
In other words, I have a string like:
任何东西,转义双引号:\",是的"这里的任何东西都不能匹配.
"anything, escaped double-quotes: \", yep" anything here NOT to be matched.
如何匹配引号内的所有内容?
How do I match everything inside the quotes?
我在想
^"((?<!\\)[^"]+)"
但是我的头在旋转,这应该是积极的还是消极的回顾?还是根本没用?
But my head spins, should that be a positive or a negative lookbehind? Or does it work at all?
如何匹配除双引号之外的任何字符,但前面没有反斜杠?
How do I match any characters except a double-quote NOT preceded by a backslash?
推荐答案
无需回看:
"([^"]|\\")*"
所以:匹配引号,并在其中:除了引号 ([^"]
) 或 转义的引号 (\\"
),任意多次(*
).
So: match quotes, and inside them: every character except a quote ([^"]
) or an escaped quote (\\"
), arbitrarily many times (*
).
这篇关于除了前面没有反斜杠的双引号外,匹配任何东西的正则表达式是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文