I'm looking for a RegEx
for multiple line email addresses.
For example:
1) Single email:
[email protected] - ok
2) Two line email:
[email protected]
karensmith@emailcom - ok
3) Two line email:
john [email protected] - not ok
karensmith@emailcom
I've tried the following:
((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\r\n)?)+)\r*
But when I test it, it seems to still match ok if there is 1 valid email address as in example 3.
I need a rule which states all email addresses must be valid.
How about:
^(((\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*(\r\n)?\s?)+)*)$
Check the beginning of the string using '^' and the end using '$'. Allow an optional whitespace character with '\s?'.
Try out http://myregexp.com/signedJar.html for testing regex expressions.
I'd split the string on [\r\n]+
and then test each address individualy.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With