Update of valid hostnames Regex #508
Closed
brenner-tobias
started this conversation in
Ideas
Replies: 2 comments
-
Thanks a lot @skipishere, @acshef, @flufftronix, @MrAnonymous722 and @elcajon for your input |
Beta Was this translation helpful? Give feedback.
0 replies
-
Closing this for now, let's keep the current version |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
While trying to allow domain names to include Umlaute, we realized that the current regex for validation if not that simple and could be improved.
Current version:
^(([a-z0-9äöüß]|[a-z0-9äöüß][a-z0-9äöüß\-]*[a-z0-9äöüß])\.)*([a-z0-9]|[a-z0-9][a-z0-9\-]*[a-z0-9])$
One suggestion is to change it to:
^((\w|\w[\w\-]*\w)\.)*(\w|\w[\w\-]*\w)$
I would go one step further and change one
*
to a+
, since we do definitely need one "." in the domain name (if I am not mistaken). So the string would look like this:^((\w|\w[\w\-]*\w)\.)+(\w|\w[\w\-]*\w)$
Any input on these ideas and also tests on regex101 with the above mentioned expression are very much appreciated.
Beta Was this translation helpful? Give feedback.
All reactions