【发布时间】:2015-01-30 23:57:42
【问题描述】:
我正在尝试构建一个正则表达式来捕获与\w{0,}?\s\d){0,} 匹配的字符串,即一个单词后跟空格,然后是一个数字。我已经模拟了here
仅用逗号分隔的前 N 个匹配项是组 1。
字符串“ opt ”之后的 N 个匹配项,仅用逗号分隔是第 2 组
字符串 ' 和/或 ' 之后的 N 个匹配项,仅用逗号分隔是第 3 组
我的尝试是这样的:((\w+?\s\d),\s+(\w+?\s\d))*(\s+and/or\s+(\w+?\s\d))*(\s+opt\s+(\w+?\s\d))*
Mind 3 opt Life 3, Prime 3 and/or Death 3 #This is not matched
Life 3, Mind 3 opt Prime 3 and/or Death 3 #This is matched
Life 3, Death 3 and/or Mind 3 opt Prime 3 #this is matched
但我确信存在我没有想到的极端情况。而且我从根本上知道这是与订单相关的,这是我不想要的。
【问题讨论】: