Hi I have a regex on an email field which works fine in most scenarios but is failing in a weird situation. Following is the regex that I am using
\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*
and following are the two similar looking email addresses on which I am testing the regex.
[email protected]
global-[email protected]
(Do not be confused with the visible text as it looks the same)
Strangely the regex fails on 1 of the email addresses. The reason I have figured out is that when I wrote the email address ([email protected]) in Evernote and pressed enter, it changed it into a link. but if you add another text (global-) to the email address after its being changed into a link, then the newly added text will not be treated as a part of the email address. I checked the complete email address in Notepad++ and found that Evernote (MS Word does the same too) has added a non-printable character at the beginning of the email address and the text I added to the email address later (after Evernote changed the text into the link) is appearing before the non printable characters. Which seems to be the reason. But I am not sure as to how to handle it using regex or using any other method. I am working on ASP.Net Webforms