My coworker and I were trying to match test emails from a given domain for automatic whitelisting.
We are trying to match emails of the form "[email protected]"
Our original RegEx was /\+test[0-9][email protected]/g
. This matches only emails containing even digits. Very strange and unexpected.
We thought that maybe it was a problem with an interaction between the @
symbol and the preceding digits, so we escaped the @
. We then tried /\+test[0-9]+\@nothing.com/g
but that only matched emails of the given form with odd digits. Also very strange.
We were able to get the regex working by leaving off the global tag at the end /\+test[0-9][email protected]/
. This matches everything, but we're not sure why.
Original RegEx test:
Escaped @ symbol RegEx test:
(I would post a third link to the working version, but I don't have enough reputation)
Can anybody help explain why we see this behaviour? What is going on here?