//URL START
$urlregex = "^(https?|ftp)\:\/\/";
// USER AND PASS
$urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$_.-]+)[email protected])?";
// HOSTNAME OR IP
$urlregex .= "[a-z0-9+\$_-]+(\.[a-z0-9+\$_-]+)*";
// PORT
$urlregex .= "(\:[0-9]{2,5})?";
// PATH
$urlregex .= "(\/([a-z0-9+\$_-]\.?)+)*\/?";
// GET Query
$urlregex .= "(\?[a-z+&\$_.-][a-z0-9;:@/&%=+\$_.-]*)?";
// ANCHOR
$urlregex .= "(#[a-z_.-][a-z0-9+\$_.-]*)?\$";
// check
if (eregi($urlregex, $url)) {echo "good";} else {echo "bad";}
但如果我有http://www.example.com/about-me/my-4*-hotel/
星號eregi
這eregi檢查是因爲星號的無效的。我該怎麼辦?
非常感謝!那工作:) – 2010-05-03 09:24:14