Mmm. I've been having a weird problem with this regex!
I'm using preg_match, which should just match a string.
I'm using;
However, if I add a - in, as such;
If I escape it with a \, it still doesn't match!
It will match all of these combinations WITH the - there, just not escaped;
my-webmaster@ewee.com
webmaster@mydomain.com
webmast@something.ws
some-thing@somewhere.co.uk
Ones that don't work;
my-webmaster@ewe-oioe.com
someone@my-domain.com
and anything with an - after the @ sign!
Anyone had experience with this regex before, and if so, any ideas why its doing that?
Thanks
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!
I'm using preg_match, which should just match a string.
I'm using;
Code:
if (!preg_match("/^[0-9a-zA-Z_.-]*@[0-9A-Za-z_.].[a-zA-Z]{2,4}/",$email)) { error("Email address $email does not seem to be valied!"); }However, if I add a - in, as such;
Code:
if (!preg_match("/^[0-9a-zA-Z_.-]@[0-9A-Za-z_.-].[a-zA-Z]{2,4}/",$email)) { error("Email address $email does not seem to be valied!"); }If I escape it with a \, it still doesn't match!
It will match all of these combinations WITH the - there, just not escaped;
my-webmaster@ewee.com
webmaster@mydomain.com
webmast@something.ws
some-thing@somewhere.co.uk
Ones that don't work;
my-webmaster@ewe-oioe.com
someone@my-domain.com
and anything with an - after the @ sign!
Anyone had experience with this regex before, and if so, any ideas why its doing that?
Thanks
Andy (mod)
andy@ultranerds.co.uk
Want to give me something back for my help? Please see my Amazon Wish List
GLinks ULTRA Package | GLinks ULTRA Package PRO
Links SQL Plugins | Website Design and SEO | UltraNerds | ULTRAGLobals Plugin | Pre-Made Template Sets | FREE GLinks Plugins!