4

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.

2 Answers 2

3

You can put a negative lookahead assertion in your existing regex:

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

See it

Sign up to request clarification or add additional context in comments.

Comments

1

I modify your regex with adding negative lookahead ( (?!\.) ).

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

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.