Regex for Matching an IPv4 Address
Matches four dot-separated groups of digits in the shape of an IPv4 address.
Published October 10, 2026
Matches four dot-separated groups of digits in the shape of an IPv4 address.
Key points
- This simple version matches the shape but not the valid range (0-255) of each octet
- A stricter pattern constraining each group to 0-255 is significantly longer and less readable
Example
^(\d{1,3}\.){3}\d{1,3}$