简体   繁体   English

Php Regex排除已经匹配的某种模式

[英]Php Regex exclude a certain pattern already matched

Hi there I need a hand with the pattern below: 嗨,我需要一只手与下面的模式:

(?<=\")([0-9\.\/])+(?=\")

Content 内容

<ul>
<li><a href="../">..</a></li>
<li><a href="1.0/">1.0/</a></li>
<li><a href="1.1/">1.1/</a></li>
<li><a href="1.23/">1.23/</a></li>
</ul>

The above pattern selects ../, 1.0/, 1.1/, 1.23/ 以上模式选择../, 1.0/, 1.1/, 1.23/

I don't want to match ../ but any permutation of number,period and / should match. 不想匹配../但数量,期间的任何排列和/应该匹配。

Give me a hand please. 请帮帮我。

Thanks as always. 一如既往地谢谢。

You can put a negative lookahead assertion in your existing regex: 您可以在现有正则表达式中添加负前瞻断言:

(?<=\")(?!\.\.)([0-9\.\/])+(?=\")
       ^^^^^^^^

See it 看见

我通过添加负前瞻( (?!\\。) )来修改你的正则表达式。

(?<=\")(?!\.)([0-9\.\/])+(?=\")

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM