Jump to content

please help in trouble here pulling hair out


redarrow

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.

Archived

This topic is now archived and is closed to further replies.

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