pattern matching

Checking whether text or data fits a described shape, such as an email address or a log line, and pulling out the parts that match.

In more detail

Regular expressions are the most common way to describe such patterns in scripts and tools. In security work, pattern matching parses log lines, detects sensitive data such as card numbers, and powers detection rules. A pattern that is too loose raises false alarms, and one that is too strict misses real cases.

Example

SSHD = re.compile(r"(Accepted|Failed) (\w+) for (?:invalid user )?(\S+) from (\S+)")

Related terms

Taught in

References