RegExp - Retrieving an IP address

October 2016


Recovering an IP address from text file, log files, web pages, etc.


The following regular expression combined with a specific command (grep, sed, etc.) should be enough :


Interpretation of the pattern
  • ([0-9]{1,3}.){3} : a sequence of one to three digits followed by a point, all repeated three times.
  • [0-9] (1,3): a number made of one to three digits.

Related :

This document entitled « RegExp - Retrieving an IP address » from CCM ( is made available under the Creative Commons license. You can copy, modify copies of this page, under the conditions stipulated by the license, as this note appears clearly.