简体   繁体   中英

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/

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\.\/])+(?=\")

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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