Skip to content

Instantly share code, notes, and snippets.

@MilkZoft
Created January 16, 2012 22:56
Show Gist options
  • Select an option

  • Save MilkZoft/1623471 to your computer and use it in GitHub Desktop.

Select an option

Save MilkZoft/1623471 to your computer and use it in GitHub Desktop.
code.jobs - Validate domain name - PHP, Regexp
<?php
$URL = "http://codejobs.biz/";
if(preg_match('/^(http|https|ftp)://([A-Z0-9][A-Z0-9_-]*(?:.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/?/i', $URL)) {
print "Valid URL";
} else {
print "Invalid URL";
}
?>
@dubrox
Copy link
Copy Markdown

dubrox commented Jan 17, 2012

la expresión regular propuesta no puede funcionar, creo que debería estar así:

<?php
preg_match('/^(http|https|ftp):\/\/([A-Z0-9][A-Z0-9_-]*(?:\.[A-Z0-9][A-Z0-9_-]*)+):?(d+)?/i', $URL)
?>

por ser precisos, la descripción del gist debería de ser "validate url"

gracias por compartir :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment