Created
October 4, 2012 13:36
-
-
Save byjml/3833565 to your computer and use it in GitHub Desktop.
Wildcard DNS validation regex.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Uses a simple regex to validate a wildcard DNS format. | |
* | |
* It validates the following entry formats: | |
* *.example.com. | |
* *.exa.m.ple.com. | |
* *.exa-mp.le.com. | |
* *.ex--ample.com. | |
*/ | |
function validate_wildcard_dns( $entry ) { | |
if ( preg_match( '/^(\\*\\.)+([a-z0-9]([-a-z0-9]*[a-z0-9])?\\.)+([a-z]{2,6})+(\\.)$/i', $entry ) ) { | |
return true; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment