Regular Expressions 101

Community Patterns

Validate unsigned non null short integer (16bits / 2 Bytes)

0

Regular Expression
PCRE (PHP <7.3)

/
^([1-9]\d{0,3}|[1-5]\d{4}|6[0-4]\d{3}|65[0-4]\d{2}|655[0-2]\d|6553[1-5])$
/
gm

Description

Validate a unsigned integer in the range 1-65535 This can for example be a UDP or TCP port number

Submitted by anonymous - 4 years ago