redarrow Posted August 30, 2006 Share Posted August 30, 2006 always a phase error on the regular exsprition please help cheers.[code]<?php$email="<a href='mailto:admin@me.com'>email address</a>";if(eregi("a{1} [a-z=\] ("|')[a-z:\][a-z0-9]+@[a-z-0-9.\][a-z]{3}('|")>\[a-z0-9]{1,20}<\a>\",$email)){echo "email correct";}else{echo "email wrong";}?>[/code] Quote Link to comment Share on other sites More sharing options...
AndyB Posted August 30, 2006 Share Posted August 30, 2006 Everything I know about regex could be written on the head of a pin, but I do have a working snippet that should be adaptable ...[code] if (!eregi("^[_a-z0-9-]+(\.[_a-z0-9-]+)*@[a-z0-9-]+(\.[a-z0-9-]+)*(\.[a-z]{2,3})$", $email)) { $err.= $email. " is not a valid email address.<br/>";}[/code] Quote Link to comment Share on other sites More sharing options...
obsidian Posted August 30, 2006 Share Posted August 30, 2006 here's another option that should be adaptable:[code]<?php$email = "<a href=\"mailto:me@mydomain.com\">email address</a>";if (!preg_match('|^<a.+?([A-Z0-9._%-]+@[A-Z0-9.-]+\.[A-Z]{2,4}).+?\>([a-z0-9 ]{1,20})</a>$|i', $email, $match)) { // not a valid email address}echo "Email Address: $match[1]<br />\n";echo "Text: $match[2]<br />\n";?>[/code]note: escaping the closing ">" of the opening a tag is not necessary, but i've got to have it there to keep the highlighter from borking.in your original, the error may simply be that you're not escaping your quotes, so the engine is jumping out of your pattern before you're intending it to do so. Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.