Url and email regular expression
5
Reg exp for finding url and email adresses. i'm using this from any projects of me. they working
$address1 = "this is a text contain a url like this http://www.morad.info/";
$address2 = "this is a text contain a email adress like this damnlittletest@kamail.com";
if (eregi('http(s)?://([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?', $address1)) {
echo "'$string' contains a URL";
}
if (eregi('\w+([-+.']\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*', $address2)) {
echo "'$string' contains a e-Mail";
}






There are currently no comments for this snippet.