Gossamer Forum
Home : Products : DBMan : Installation :

A doozy of a regular expression

Quote Reply
A doozy of a regular expression
I've come across the following regular expression for checking to see if an email address is the correct format:

Code:
if ($email =~ /(@.*@)|(\.\.)|(@\.)|(\.@)|(^\.)/
| | $email !~ /^.+\@(\[?)[a-zA-Z0-9\-\.]+\.([a-zA-Z]{2,3}|[0-9]{1,3})(\]?)$/) {

If it matches the first regular expression or doesn't match the second, it's not a correct format. (The script I got it from explains how it works, but I just take his word for it! Smile )

How would I translate that into a valid expression to put into the .cfg file?


------------------
JPD


[This message has been edited by JPDeni (edited January 19, 1999).]
Quote Reply
Re: A doozy of a regular expression In reply to
I've seen that before! It came up a long time ago on Matt's Script Archive mailing list.

Since the valid expr field only accepts one regexp, you couldn't really use this in their. What you would want to do is put it in manually in validate_records and replace $email with $in{'Email'} (or something similiar).

However, my experience has been, this isn't much more effective then '.+\@.+\..+' regexp which just checks to make sure the email is something at something dot something.

You can never check that the address is real, as someone can always just enter 'a@a.com' and it will pass, but isn't good.

Cheers,

Alex
Quote Reply
Re: A doozy of a regular expression In reply to
Thanks, Alex! I guess I just thought that huge regular expression was impressive! Smile

I find that a lot of people don't know how to enter their email addresses at all. I get a lot that are "somebody@aol" or even just "somebody." At least this will let them know that they need to enter their addresses in the correct format.

Thanks again, Alex.


------------------
JPD