Home  >  Article  >  Backend Development  >  正则表达式判断email和URL,帮忙看看有没有要补充的._PHP

正则表达式判断email和URL,帮忙看看有没有要补充的._PHP

WBOY
WBOYOriginal
2016-06-01 12:34:48918browse

正则表达式


echo 'a:'.htmlspecialchars($a);
echo '
a1:';
$a1 = eregi_replace('(^[_.][:alnum:]-]+@([[:alnum:]][[:alnum:]-]*.)+[[:alpha:]]{2,3}$)',' \1 ', $a) ;
echo htmlspecialchars($a1);
echo "
a1:$a1";

echo '
a2:';
$a2 = eregi_replace('([[:alnum:]]+://([[:alnum:]][[:alnum:]-]*\.)+[[:alpha:]]{2,3}([#\?/\\][^#\?/\\][:space:]][^[:space:]]*)?)',
      '\1', $a);
echo htmlspecialchars($a2);
echo "
a2:$a2";
// eregi('^[_.][:alnum:]-]+@([[:alnum:]][[:alnum:]-]*\.)+[[:alpha:]]{2,3}$',$a) or die("not a email");
?>






    
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn