脚本宝典收集整理的这篇文章主要介绍了php – 可变长度的正则表达式,脚本宝典觉得挺不错的,现在分享给大家,也给大家做个参考。
(?<![\s]*?(\"|&quot;)")WORD(?![\s]*?(\"|"))
正如你所看到的,我试图匹配WORD的所有实例,除非它们在“引号”内.所以…
WORD <- Find this "WORD" <- Don't find this " WORD " <- Also don't find this,even though not touching against marks "WORD" <- Dont find this (I check " and " so works after htMLsPEcialchars)
我相信我的正则表达式会完美地工作如果我没有收到错误:
Compilation Failed: lookbehind assertion is not fixed length
考虑到外观的局限性,有没有办法做我想做的事情?
如果您能想到其他任何方式让我知道.
非常感谢,
马修
附: WORD部分实际上包含Jon Grubers URL检测器
if (PReg_match( '/WORD # Match WORD (?! # unless IT\'s possible to match the following here: (?: # a string of characters (?!") # that contains neither " [^"] # nor " )* # (any length),("|") # followed by either " or " (remember which in \1) (?: # Then match (?:(?!\1).)*\1 # any string except our quote char(s),followed by that quote char(s) (?:(?!\1).)*\1 # twice,)* # repeated any number of times --> even number (?:(?!\1).)* # followed only by strings that don\'t contain our quote char(s) $ # until the end of the string ) # End of lookahead/sx',$subject))
以上是脚本宝典为你收集整理的php – 可变长度的正则表达式全部内容,希望文章能够帮你解决php – 可变长度的正则表达式所遇到的问题。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。