regex for ip address(ipv4)

match an ipv4 address

(\b25[0-5]|\b2[0-4][0-9]|\b[01]?[0-9][0-9]?)(\.(25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)){3}
192.168.1.1 127.0.0.1 0.0.0.0 255.255.255.255 256.256.256.256 999.999.999.999 1.2.3 1.2.3.4

Matches an ip address(version 4)

Internet Protocol (ip) addresses are the numerical identifiers of each device connected to a computer network that uses Internet Protocol for communication. This 32 bit address scheme is the first version of ip addresses.

The addresses are separated by period (.).

ip addresses are of the range 0.0.0.0 - 255.255.255.255

This expression will match a given string for an ip address and also considers the range.


Cheatsheet

expr usage
/[abcd]/ matches any character in square brackets
/[0-9]/ matches all digits
/(hello){4}/ matches "hellohellohellohello"
iHateRegex
by geon