Title |
Test
Find
Pattern Title
|
Expression |
(?=^.{1,254}$)(^(?:(?!\d+\.)[a-zA-Z0-9_\-]{1,63}\.?)+(?:[a-zA-Z]{2,})$) |
Description |
Validates MS FQDNs. 1) Entire fqdn less than 255 chars. 2) Host and domain names may contain an underscore. 3) 1st char can be a number. 4) No part can be all numbers. 5) Allows any TLD
Works in C#. Based on Remi Sabourin's regex |
Matches |
host.domain.com | _host.domain.com | 1host-2._ldap.domain.com |
Non-Matches |
33.domain.com | host..com | this_really_long._fully_qualified_domain_name._contains_257_characters_w |
Author |
Rating:
Not yet rated.
Scott Mulcahy
|
Source |
|
Your Rating |
|
Title: example matches doesn't match ...
Name: Gerfried Fuchs
Date: 5/3/2007 5:06:13 AM
Comment:
The match for 1host-2._ldap.domain.com doesn't work out because of the negative look ahead for \d+\. which this matches and thus makes the pattern fail.
Title: Updated
Name: Scott Mulcahy
Date: 4/18/2007 5:31:45 PM
Comment:
I couldn't remember my username or password so I could properly update the expression.
(?=^.{1,254}$)(^(?:(?!\d+\.|-)[a-zA-Z0-9_\-]{1,63}(?<!-)\.?)+(?:[a-zA-Z]{2,})$)
Title: Gives false positives
Name: Guest User
Date: 8/16/2006 3:39:41 PM
Comment:
Labels in domains cannot start or end with hyphens. This expression will return a match for a-.com when it should not.