Jump to content

Recommended Posts

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

[code]
<?php

$email="<a href='mailto:[email protected]'>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]
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]
here's another option that should be adaptable:
[code]
<?php
$email = "<a href=\"mailto:[email protected]\">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.
This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.