Regular Expressions 101

Sponsor⁠s

Community Library

Community Library Entry

4

Regular ExpressionOpen Workspace

/
^(?:_?(?>[a-z\d][a-z\d-]{0,61}[a-z\d]|[a-z\d])\.)*(?:_?(?>[a-z\d][a-z\d-]{0,61}[a-z\d]|[a-z\d]))\.?$
/
i

Description
Created·2016-03-10 19:44
Type·Match
Flavor·PCRE (Legacy)

Validates that a DNS hostname is well-formed only. You will still need to check that the overall length of the hostname, including the implied trailing "." (if not present), does not exceed 255 bytes.

Submitted by Jeff Walter
Open Workspace