Regular Expressions 101

Community Patterns

IPv4 address with optional CIDR suffix


Regular Expression
ECMAScript (JavaScript)



Matches any valid IPv4 address with, optionally, a CIDR suffix. to and to

Use the following regex if you don't want to allow the CIDR suffix.


(removed (?:\/(?:[12]?[0-9]|3[0-2]))? from the end)

Submitted by MAZ01001 - 5 months ago