Validate url regex

Any idea why this function doesn’t work…


function ValidateURL($url)
	{
		if(!preg_match('/^(http|ftp|https):\\/\\/[\\w\\-_]+(\\.[\\w\\-_]+)+([\\w\\-\\.,@?^=%&:/~\\+#]*[\\w\\-\\@?^=%&/~\\+#])?', $url))
		{
			return false;
		}
		else
		{
			return true;
		}

	}

I get the following error:

Warning: preg_match() [function.preg-match]: Unknown modifier ‘~’ in /Applications/MAMP/htdocs/domain.co.uk/public_html/classes/user.class.php on line 556

Shouldn’t the two / before the two ~ be escaped?

Hi - I just tried that, now i’m getting:

Warning: preg_match() [function.preg-match]: No ending delimiter ‘/’ found in /Applications/MAMP/htdocs/domain.co.uk/public_html/classes/user.class.php on line 556

You delimite the regex with / at the beginning, you have to put a / at the end too.