【发布时间】:2019-10-29 01:31:38
【问题描述】:
已阅读以下内容,这些内容与我面临的问题有一些重叠(双关语!): preg_match_all how to get *all* combinations? Even overlapping ones Overlapping matches with preg_match_all and pattern ending with repeated character
但是,我真的不知道如何将他们的答案应用到我的问题上,这有点复杂。
我与 preg_match_all() 一起使用的正则表达式:
/.{240}[^\[]Order[^ ][^\(].{9}/u
使用以下字符串:
56A. Subject to the provisions of this Act, any decision of the Court or the Appeal Board shall be final and conclusive, and no decision or order of the Court or the Appeal Board shall be challenged, appealed against, reviewed, quashed or called into question in any court and shall not be subject to any Quashing Order, Prohibiting Order, Mandatory Order or injunction in any court on any account.[20/99; 42/2005]
我打算让它精确匹配 3 次。第一场比赛在结束前有 9 个字符的“取消令”。第二场比赛在结束前有 9 个字符的“禁止令”。第三场比赛在结束前有 9 个字符的“强制顺序”。
但是,正如预期的那样,它只匹配第一个,因为预期的匹配是重叠的。
我应用了我在其他帖子中读到的内容,我尝试了这个:
(?=(.{240}[^\[]Order[^ ][^\(].{9}))
我仍然没有得到我需要的东西。
我该如何解决这个问题?
【问题讨论】:
-
您正在寻找这样的东西吗? regex101.com/r/nohGwr/2
-
或
/\b\w+\s+Order\b/?见this demo。为什么要添加.{240}和.{9}? -
如果只有two have a non-space
[^ ]afterorder,为什么要期待三次。 -
当您说重叠时,您指的是哪个文本?结尾前的 9 个字符是什么意思?
标签: php regex preg-match-all