4 ms·
I recently had a requirement to transform email addresses within free text into clickable mailto: links. That needs a regex. /[^ ]+@[^ ]+/ is OK except for tra
by mappu 4y ago
I recently had a requirement to transform email addresses within free text into clickable mailto: links. That needs a regex.
/[^ ]+@[^ ]+/ is OK except for trailing punctuation, double @'s, and it definitely doesn't work with that quoted example. The first Rails one in this post /\A[^@]+@([^@\.]+\.)+[^@\.]+\z/ is at least better than what I came up with - I'll take a battle-tested regex if it's on offer.