Regular expression for validating hostname

d))))|:))|(:(((:[0-9A-Fa-f]))|((:[0-9A-Fa-f]):((25[0-5]|2[0-4]d|1dd|[1-9]? is a syntaxticly invalid NTP server hostname.) The reason I want to make this basic validation is because I am building a Web app to configure a server. d)))|:))|(([0-9A-Fa-f]:)(((:[0-9A-Fa-f]))|((:[0-9A-Fa-f])? d))))|:))|(([0-9A-Fa-f]:)(((:[0-9A-Fa-f]))|((:[0-9A-Fa-f]):((25[0-5]|2[0-4]d|1dd|[1-9]? You can test them out in your browser using the excellent Regex Pal site. ^(([0-9]|[1-9][0-9]|1[0-9]|2[0-4][0-9]|25[0-5])\.)([0-9]|[1-9][0-9]|1[0-9]|2[0-4][0-9]|25[0-5])$ [Updated: 13/Jan/2015 – thanks to Mike in the comments for pointing out the bug in the old version! d)))|:))|(([0-9A-Fa-f]:)(((:[0-9A-Fa-f]))|((:[0-9A-Fa-f])? The original specification of hostnames in RFC 952, mandated that labels could not start with a digit or with a hyphen, and must not end with a hyphen.

A regex is a bad way to achieve what I think you are trying to achieve, although you haven't actually stated what you are trying to achieve. A better way would be to perform a DNS lookup on the hostname and verify that it resolves to an IP address (be that IPv6 or IPv4) and that when you connect to that IP address on port 123, you get a valid NTP protocol response.The app presents the user with a form, for which one of the fields is .I want to make a quick validation in the browser before sending any server configurations partly to avoid XSS attacks, and partly to provide quick feedback to the user.This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form.For help clarifying this question so that it can be reopened, visit the help center.

Search for regular expression for validating hostname:

regular expression for validating hostname-27regular expression for validating hostname-2regular expression for validating hostname-60regular expression for validating hostname-23

Leave a Reply

Your email address will not be published. Required fields are marked *

One thought on “regular expression for validating hostname”