正则表达式判断email和URL,帮忙看看有没有要补充的._PHP
程序员文章站
2022-04-26 23:22:57
...
正则表达式
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");
?>
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");
?>