: This article mainly introduces the judgment of Email + URL and the automatic conversion function. if you are interested in the PHP Tutorial, please refer to it. Function validateEmail ($ email)
{Return eregi ("^ [_ a-z0-9-] + (\. [_ a-z0-9-] +) * @ [a-z0-9-] + (\. [a-z0-9-] + )*(\. [a-z] {2, 3}) $ ", $ email );
}
Function validateURL ($ url)
{Return eregi ("^ (ht | f) tp: //) ([a-z0-9-] + (\. [a-z0-9-] + )*(\. [a-z] {2, 3}) | ([0-9] {1, 3 }\.) {3} ([0-9] {1, 3}) (/| \?) A-z0-9 ~ # % & '_ \+ = :\? \.-] *) $ ", $ Url );
}
Function convertURLS ($ text)
{$ Text = eregi_replace ("(ht | f) tp: // www \. | www \.) ([a-z0-9-] + (\. [a-z0-9-] + )*(\. [a-z] {2, 3}) (/| \?) A-z0-9 ~ # % & \\/'_ \+ = :\? \.-] *) "," Http: // www. \ 3 ", $ text );
$ Text = eregi_replace ("(ht | f) tp: //) ([a-z0-9-] + (\. [a-z0-9-] + )*(\. [a-z] {2, 3}) | ([0-9] {1, 3 }\.) {3} ([0-9] {1, 3}) (/| \?) A-z0-9 ~ # % & '_ \+ = :\? \.-] *) "," \ 0 ", $ text );
Return $ text;
}
Function convertMail ($ text)
{$ Text = eregi_replace ("([_ a-z0-9-] + (\. [_ a-z0-9-] +) * @ [a-z0-9-] + (\. [a-z0-9-] + )*(\. [a-z] {2, 3}) "," \ 0 ", $ text );
Return $ text;
}
Function convertAllLinks ($ text)
{$ Text = convertURLS ($ text );
$ Text = convertMail ($ text );
Return $ text;
}
?>
The above introduces the judgment of Email + URL and the automatic conversion function, including the content, hope to be helpful to friends who are interested in the PHP Tutorial.