Regular Expressions 101

Community Patterns

IP adress or masks

0

Regular Expression
PCRE (PHP <7.3)

/
^(((25[0-5]|2[0-4][0-9]|1[0-9]{2}|[1-9]{1}[0-9]|[1-9]).){1}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]).){2}((25[0-5]|2[0-4][0-9]|[1]{1}[0-9]{2}|[1-9]{1}[0-9]|[0-9]){1}))$
/
gm

Description

Match any IP adress or Subnet masks and split all bytes in capture groups

Submitted by SkullPand4 - 8 years ago