Cakkie
December 3rd, 2002, 03:02 PM
Anyone know how to build the pattern?
I'm trying to validate an email address in the form of user@host. I don't even need the tld part (.com, .be, .net).
I read the helpfile topic in that, which explains things, but when I try to match, it always returns true.
This is the pattern I though it should be...
[a-zA-Z0-9\-\._]+\@[a-zA-Z0-9\-\._]+
the first part [a-zA-Z0-9\-._]+ would be the part before the @, containing at least 1 character from a-z, A-Z, 0-9, dash (\-), dot (\.) or underscore (_).
the same goes for the last part.
The middle is just an escaped @, to match the @ sign.
The problem is that it matches any string that has at least one charecter before and after the @ sign, no matter what.
I think I need an expression that only give these where all characters match.
Examples of addresses with the value it should be, and what it gives me
user@host : true, gives true
user@host@host: false, gives true
us#er@host: false, gives true
@user.host: false, gives false
Anyone know what expression I should use, and knows why that is?
I'm trying to validate an email address in the form of user@host. I don't even need the tld part (.com, .be, .net).
I read the helpfile topic in that, which explains things, but when I try to match, it always returns true.
This is the pattern I though it should be...
[a-zA-Z0-9\-\._]+\@[a-zA-Z0-9\-\._]+
the first part [a-zA-Z0-9\-._]+ would be the part before the @, containing at least 1 character from a-z, A-Z, 0-9, dash (\-), dot (\.) or underscore (_).
the same goes for the last part.
The middle is just an escaped @, to match the @ sign.
The problem is that it matches any string that has at least one charecter before and after the @ sign, no matter what.
I think I need an expression that only give these where all characters match.
Examples of addresses with the value it should be, and what it gives me
user@host : true, gives true
user@host@host: false, gives true
us#er@host: false, gives true
@user.host: false, gives false
Anyone know what expression I should use, and knows why that is?