Lets say there are two default HTML email tags:
<a href="mailto:test@test.com">test@test.com</a>
<a href="mailto:test@test.com" nosecure>test@test.com</a>
I want to find only the email Tag without the nosecure
tag in PHP. So something like \<a\b(?![^>]*\bnosecure\b)[^>]*>[^<]*<\/a>
will do the trick so far.
But now I want to have one group for the value of the href
tag and one group for the text inside the <a>...</a>
Tag. Second group is easy:
\<a\b(?![^>]*\bnosecure\b)[^>]*>([^<]*)<\/a>
But how do I get the first group? There can be unlimited other chars after/before the href tag and also the nosecure can be after/before the href tag.
How do I get a regex group for the value of href="mailto:<group>"
. Also, there can be '
instead of "
.
Test cases and my current attempt: https://regex101.com/r/RNEZO3/2
Thanks for any help :)
greetings