Regular Expressions 101

Community Patterns

Community Library Entry

0

Regular Expression
Python

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

Description

Grabs an IPv4 address, and if it has a CIDR slash notation, then grab that too.

Submitted by dboyd42 - 3 years ago (Last modified a year ago)