IPv4 CIDR Notation
intermediateMatches IPv4 addresses with CIDR subnet prefix like 192.168.1.0/24.
ipcidrsubnetnetwork
Pattern
/(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)/(?:3[0-2]|[12]?\d)/gTry It
0 of 6 strings matched
Explanation
Matches an IPv4 address (four octets 0-255) followed by a slash and a CIDR prefix length (0-32).
Test Strings
Matching
- 192.168.1.0/24
- 10.0.0.0/8
- 172.16.0.0/12
Non-matching
- 192.168.1.0
- not-a-cidr
- 10.0.0/8
Language Compatibility
| Language | Support |
|---|---|
| JS | Full support |
| PYTHON | Full support |
| JAVA | Full support |
| PHP | Full support |
| GO | Full support |
Code Snippets
const regex = /(?:(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\.){3}(?:25[0-5]|2[0-4]\d|[01]?\d\d?)\/(?:3[0-2]|[12]?\d)/g;
const text = "your text here";
const matches = text.match(regex);
console.log(matches);