0

I have this string:

<a href="..">..</a></td><a href="Example.pdf">Example.pdf</a>

I would like to get all the links and I do so with this regular expression:

href=\"([^/]*?)\"

However, I would like the regular expression to ignore this specific string:

..

How would I modify my regular expression to achieve this exclusion?

Cœur
  • 34,719
  • 24
  • 185
  • 251
etayluz
  • 14,907
  • 20
  • 95
  • 141

1 Answers1

0

This one based on a negative lookahead should work : <a.+?href=["'](?!\.\.)([^"']+)["'].*?>(.+?)<\/a>

Use Group 1 to extract link of each match

Demo

Stephane Janicaud
  • 3,416
  • 1
  • 11
  • 16