sysadmin:kb:helpful_regular_expressions

Helpful RegEx

Perl:

(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)

Source: http://ipregex.com/

If you're scanning an INI file, this regex will ignore commented lines1)

^(?:\w+=)(?:(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d\d|[1-9]?\d)$

This regex will match as long as the line begins with a word.


1)
Line comments in INI files begin with a semicolon (;)
  • sysadmin/kb/helpful_regular_expressions.txt
  • Last modified: 2020/01/27 19:07
  • by mjorgensen