Skip to content

Instantly share code, notes, and snippets.

@bmakowski
Last active December 13, 2017 16:15
Show Gist options
  • Save bmakowski/14dbf76f9ba7ec0957c0b763a4df5384 to your computer and use it in GitHub Desktop.
Save bmakowski/14dbf76f9ba7ec0957c0b763a4df5384 to your computer and use it in GitHub Desktop.
Preg Match domain name
<?php
if( !preg_match('/^(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}$/', $domain) ){
// didn't match return error
return false;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment