I want to detect emails in text format so that I can put an anchor tag over them with mailto tag in anchor. I have the regex for it but the code also detects emails which are already encapsulated by anchor tag or is inside the anchor tag mailto parameter.
My regex is:
([\w-]+(\.[\w-]+)*@([a-z0-9-]+(\.[a-z0-9-]+)*?\.[a-z]{2,6}|(\d{1,3}\.){3}\d{1,3})(:\d{4})?)
But it detects 3 matches in the following sample text:
ttt <a href='mailto:someone@example.com'>someemail@mail.com</a> abc email@email.com
I want only email@email.com to be matched by the regex.