Url and email regular expression





5
Date Submitted Tue. May. 29th, 2007 3:10 AM
Revision 1 of 1
Helper morad
Tags Email | Expression | RegExp | Regular | URL
Comments 0 comments
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";
}

 

murat küçükosman

www.morad.info
http://www.morad.info/

Comments

There are currently no comments for this snippet.

Voting

Votes Down