Keep It Simple, Stupid | |
PerlMonks |
Checking on multiple email addresses in a stringby c (Hermit) |
on Jul 22, 2001 at 18:34 UTC ( [id://98822]=perlquestion: print w/replies, xml ) | Need Help?? |
c has asked for the wisdom of the Perl Monks concerning the following question:
I've written a control panel of sorts which will allow users to update the list of email aliases they have set up for their domain. In this current version of the panel, each alias can have only one true destination email address rather than multiple recipients. As a result of this, until I add that feature :-) I need to double check to make sure that end users do not input more than one alias for the valid destination email. I am using the following regex to check a formfield value to see if what appears to be more than one email addr exists in its value:
It seems poorly formed to me, but works. I am not really certain why i need the or operator within my first grouping, but trying (\w\.\-)+ doesnt seem to work even though I use a similar regex, [^\w\.\-] to test for illegal characters within an email address.
It might be easier to just check for more than one \@ but I am not sure how to say one is okay, but two is not within regex. The above regex maps out an email address followed by one or two characters including the possibility of whitespace followed by the beginning of another email address which will include another \@ humbly -c
Back to
Seekers of Perl Wisdom
|
|