Regular Expressions 101

Community Patterns

Community Library Entry

1

Regular Expression
Python

r"
^((1\d{2}|2[0-4]\d|25[0-5]|[1-9]?\d)(\.(?=\d)|(?!\d))){4}(/([12]?\d|3[0-2]))?$
"
gm

Description

Strict validator for IPv4 with optional CIDR Disallows 00 in any octet

Submitted by ophers - a year ago