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:
} elsif { ( $add_destination =~ /^(\w|\.|\-)+\@(\w)+\.(\w)+(.|..)(\w)
++\@/ )
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 \@
I know that a couple modules like Email::Valid
could be my solution for checking for illegal characters, but I know their must be a better solution for checking for multiple \@ within a string.
humbly -c
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.