Regular Expressions 101

Community Patterns

Hostname-Match not found

0

Regular Expression
PCRE (PHP <7.3)

/
\^([a-zA-Z0-9](?:(?:[a-zA-Z0-9-]\*|(?<!-)\.(?![-.]))\*[a-zA-Z0-9]\+)?)$
/

Description

I'm trying to match a hostname input with the following properties: a-z A-Z 0-9 : - are allowed ; doesnot start or end with - ; "." can be used to separate different labels of the hostname. But gives no match for this regex: ^(a-zA-Z0-9?)$
please help me.

Submitted by Revathy - 9 years ago