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:[email protected]'>[email protected]</a> abc [email protected]
I want only [email protected] to be matched by the regex.