Programmer Question
I need to highlight an email addresses in text but not highlight them if contained in HTML tags, content, or attributes.
For example, the string example@example.com
must be converted to <a href="mailto:example@example.com">example@example.com</a>
But email addresses in the string <a href="mailto:example@example.com">example@example.com</a>
must not be processed.
I've tried something like this regexp:
(?<![":])[a-zA-Z0-9._%-+]+@[a-zA-Z0-9._%-]+.[a-zA-Z]{2,6}(?!")
but it doesn't work properly.
Find the answer here
No comments:
Post a Comment