RegEx for"但不是\"

时间:2014-05-17 12:13:54

标签: regex escaping

我有以下输入:

download "http://google.com/index.html" "C:\Users\%username%\AppData\Roaming\test.zip"
keyboard "\"test\""

我需要一个正则表达式,它给出了引号之间的内容,如

http://google.com/index.html
C:\Users\%username%\AppData\Raming\test.zip
\"test\"

重要的是它忽略了“角色。

1 个答案:

答案 0 :(得分:2)

AutoIT的正则表达式引擎有一些限制,因此您需要匹配包含它周围引号的字符串,然后删除它们。这可以通过capturing group轻松完成,这意味着您需要使用匹配结果的第1组而不是整个匹配结果:

"((?:[^\\"]|\\.)*)"

将匹配整个字符串。

<强>解释

"         # Match "
(         # Match and capture into group 1:
 (?:      # Start of non-capturing group: Either...
  [^\\"]  # match one character that's neither a quote nor a backslash
 |        # or...
  \\.     # match an escaped character.
 )*       # Repeat as needed
)         # End of capturing group
"         # Match "