我需要为下面的模式选择引号内的单词
I "capture_0" in XXX_PAGE
I "capture_0" and "capture_1" in XXX_PAGE
I do "capture_0" in XXX_PAGE
I do "capture_0" and "capture_1" in XXX_PAGE
I perform "capture_0" in XXX_PAGE
I perform "capture_0" and "capture_1" in XXX_PAGE
I validate "capture_0" in XXX_PAGE
I validate "capture_0" and "capture_1" in XXX_PAGE
I search for "capture_0" in XXX_PAGE
I search for "capture_0" and "capture_1" in XXX_PAGE
I search for "capture_0" or "capture_1" in XXX_PAGE
I search for "capture_0" and_or "capture_1" in XXX_PAGE
我尝试了各种最不正确的一个是..我无法分开AND和其他单词执行搜索等 - 有人可以帮忙吗。
/^I ((.*?)|(.*?) and (.*?)) in (.*?)_Page$/
并且仅捕获要捕获的单词而不是引号。这些是最后的例子。 XXX 可以是任何东西。给出何时不需要捕获,因此在实际示例中忽略它。
您可以编写一个主要使用
XXX_PAGE
信息的表达式,例如:
/(?:"([^"]*)"\s+(?:\band\b|\bor\b|\band_or\b))?\s+"([^"]*)"\s+in\s+[^_]{3}_page$/gi
或
(?i)(?:["']([^"']*)["']\s+(?:\band\b|\bor\b|\band_or\b))?\s+["']([^"']*)["']\s+in\s+[^_]{3}_page$
如果你可能有单引号。
(?i)
:添加敏感标志以使事情变得简单。(?:["']([^"']*)["']\s+(?:\band\b|\bor\b|\band_or\b))?
:第一个报价的第一个可选组。["']([^"']*)["']
:第二句话。\s+in\s+[^_]{3}_page
:结束部分。$
:结束。如果需要,请确保在末尾添加额外的
\s*
。
/(?:"([^"]*)"\s+(?:\band\b|\bor\b|\band_or\b))?\s+"([^"]*)"\s+in\s+[^_]{3}_page\s*$/gmi