RegExp - Retrieving an IP address

April 2018

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.
Published by netty5. Latest update on January 10, 2010 at 05:23 AM by jak58.
This document, titled "RegExp - Retrieving an IP address," is available under the Creative Commons license. Any copy, reuse, or modification of the content should be sufficiently credited to CCM (