Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
PCRE (PHP <7.3)

/
(?=\A[-a-z0-9]{1,63}\Z)\A[a-z0-9]+(-[a-z0-9]+)*\Z
/
mgi

Description

RFC 1123 compatible RegEx for a hostname (not a domain name), inspired by chapter 7.15 from Regular Expressions Cookbook.

Submitted by anonymous - 10 years ago