I am trying to create a regex that will return true only when the string only contains an anchor like so <a href="www.something.com">Link</a>
.
Currently I have the following regex which almost works (?=.*^<a)(?=.*<\/a>).*/g
This works for the following scenarios:
<a href="www.something.com">Link</a>
- Matches successfully
words before <a href="www.something.com">Link</a>
- No matches - success
<a href="www.something.com">Link</a> words after
- finds match - Not successful :(
I think I'm pretty close, I just need to know how to not find a match if there are any characters after the </a>
.