How can use regex to make sure that is only a single slash end the end of an URL or any input string?
$url = 'http://example.com//';
if(!preg_match('/\/$/', $url))
{
echo 'the url must ends with a \'/\'';
}
This accepts two or more slashes which is not correct.
I think you can do like this:
I have not tested it, the idea is to test if there is not a
/before the/at the end of the string (and in this version to allow the start of a string as well, so the"/"string is valid as well.