Asterisk in eregi
Posted
by Mihai
on Stack Overflow
See other posts from Stack Overflow
or by Mihai
Published on 2010-04-30T08:49:24Z
Indexed on
2010/04/30
8:57 UTC
Read the original article
Hit count: 318
//URL START
$urlregex = "^(https?|ftp)\:\/\/";
// USER AND PASS
$urlregex .= "([a-z0-9+!*(),;?&=\$_.-]+(\:[a-z0-9+!*(),;?&=\$.-]+)?@)?";
// 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";}
but what if I have http://www.example.com/about-me/my-4*-hotel/
That eregi check isn't valid because of the asterisk. What should I do?
© Stack Overflow or respective owner