Regular Expressions 101

Community Patterns

IPv4 Subnet Mask Verification

-1

Regular Expression
PCRE (PHP <7.3)

/
^(255)\.(0|128|192|224|240|248|252|254|255)\.(0|128|192|224|240|248|252|254|255)\.(0|128|192|224|240|248|252|254|255)
/
gm

Description

Intended to verify a valid IPv4 subnet mask against every valid IPv4 subnet mask possible using octet format. Does not check against a string that is using CIDR notation.

Submitted by anonymous - 4 years ago