Jump to content

Archived

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

redarrow

please help in trouble here pulling hair out

Recommended Posts

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]

Share this post


Link to post
Share on other sites
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]

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites

×

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.