Tip Cache
Your source for tech tips
Tip: Regular Expression to Validate a URL
Posted By: apeiro
This regular expression can validate most HTTP/FTP URLs
Ta da.
<?php
$is_valid = preg_match('@((ht|f)tps?://([-\w\.]+)+(:\d+)?(/([\w/_\.]*(\?\S+)?)?)?)@', $url);
?>
