..." without the other ones? Wou" /> ..." without the other ones? Wou" /> ..." without the other ones? Wou"/>

Stop matching after first occurence (single line)

54 views Asked by At

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!

2

There are 2 answers

0
user20693069 On BEST ANSWER

Try

<a[^>]*>[^<]*</a>
3
bragi On

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>)