Hi,
May be I got up on the wrong side of the bed but
why this simple regex doesn’t work ?
if (preg_match("#^[0-9a-z\\/]+#i", "/user/1/***")) {
echo "A match was found.";
} else {
echo "A match was not found.";
}
// give A match was found.
Thanks in advance.
Bye
Blue1
2
It works, copied it straight into shell and it finds the match so everything’s right there.
Thanks for the reply but
It shouldn’t match a string with special chars
/user/1/***
You need to add “$” to the end.
Or do:
if ( preg_match( '~[^0-9A-Za-z\\/]~', $s ) )
echo "Invalid! Must contain only 0-9 A-Z / ...";