Jump to content


please help in trouble here pulling hair out

  • Please log in to reply
2 replies to this topic

#1 redarrow

  • Members
  • PipPipPip
  • Advanced Member
  • 7,308 posts
  • Locationlondon

Posted 30 August 2006 - 06:24 AM

always a phase error on the regular exsprition please help cheers.


$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";


echo "email wrong";



Wish i new all about php DAM i will have to learn

#2 AndyB

  • Staff Alumni
  • Advanced Member
  • 5,465 posts
  • LocationToronto

Posted 30 August 2006 - 12:40 PM

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 ...

        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/>";

Legend has it that reading the manual never killed anyone.
My site

#3 obsidian

  • Staff Alumni
  • Advanced Member
  • 3,202 posts
  • LocationSeattle, WA

Posted 30 August 2006 - 12:57 PM

here's another option that should be adaptable:
$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";

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.
You can't win, you can't lose, you can't break even... you can't even get out of the game.

while (count($life->getQuestions()) > 0)
{   $life->study(); } ?>
  LINKS: PHP: Manual MySQL: Manual PostgreSQL: Manual (X)HTML: Validate It! CSS: A List Apart | IE bug fixes | Zen Garden | Validate It! JavaScript: Reference Cards RegEx: Everything RegEx

0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users