Home > Mobile >  Stop matching after first occurence (single line)
Stop matching after first occurence (single line)

Time:12-06

How could I just match the first anchor tag and not all of them until the last one? Basically all of this: "<a...>...</a>" without the other ones? Would I need to sub the string before matching?

enter image description here

Here's what I got: https://regex101.com/r/hXh2JI/1

Thank you!

CodePudding user response:

Try

<a[^>]*>[^<]*</a>

CodePudding user response:

I think this regex does what you're asking for. Add the global and multi line regex flags to capture all cases of <a> ... </a>.

Regex looks like this:

(<a>.*<\/a>)
  • Related