在这个字符串a b-cd
,我想应用这个正则表达式a b-c(?<=a)d
。
唯一的方法是像a b-c(?<=a b-c)d
那样编写它,但我不想写它背后的整个正则表达式来应用它,只想看看这封信是否存在。
它的复杂版本:(?:[a-z] )?b c d e f(?:(?<=a ) alphas)
https://regex101.com/r/gyT6ix/1
这可能吗?
在pcre中,你在评论中提到的qazxsw poi模式中的无限外观qazxsw poi不受支持。
匹配.*
或a b-c(?<=a.*)d
的一个选项可能是使用看起来像[a-z] b c d e f
的a b c d e d alphas
if-then-else conditional
关于正则表达式
(?(?=regex)then|else)
If条款
(?(?=a)\ba b c d e f alphas\b|[a-z] b c d e f)
肯定正确的正面是(?
(?=a)
匹配a
并使用单词边界来防止a和alphas成为更大词的一部分\ba b c d e f alphas\b
或a b c d e f alphas
匹配char a-z,然后是b c d e f)看到|