Regular expressions are very powerful and are widely used for pattern matching in the cyber security domain, be it dealing with parsing log files, Qualys or Nessus reports, or outputs produced by Metasploit, NSE or any other service scanning or exploit script. The module that provides support for regular expressions in Python is re. There are a few important methods that we will be using with Python regular expressions (the re module), which are explained as follows:
match() |
This determines if the regular expression finds a match at the beginning of the string re.match(pattern,string,Flag=0). The flags can be specified with the | or operator. The most commonly used flags are re.Ignore-Case, re.Multiline, and re.DOTALL. These flags can be specified with the or operator as (re.M| re.I). |
search() |
Unlike match, search doesn't look for... |