Created
January 17, 2018 02:52
-
-
Save bmakowski/c7085f60af03b2432649f80e9fed3263 to your computer and use it in GitHub Desktop.
Validate domain ragular expression
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
This allows only domains with "." for example "example.com" | |
^(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.){1,126}(?!\d+)[a-zA-Z\d]{1,63}$ | |
This allows also one-name domains like "localhost". "." is optional | |
^(?!\-)(?:[a-zA-Z\d\-]{0,62}[a-zA-Z\d]\.?){1,126}(?!\d+)[a-zA-Z\d]{1,63}$ |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment