Regular Expressions (Regex)

Many parameters, e.g. --include or --exclude expect regular expressions (short: regex) as values. They allow to match more than one exact string.

Regex in Practice

A regular expression is a special text string for describing a search pattern. You are probably familiar with wildcard notations such as *.txt to find all text files in a file manager. The regex equivalent is .*\.txt$. The following graphic explains each of the expressions components.

expressions components

So regular expressions have the same purpose but an other, much more powerful syntax compared to wildcards.

Ignore Case

To match a string while ignoring the case of its letters, prefix (?i) to the pattern.

Example

The regex pattern h?llo would match to the strings hello or hallo (and also h1llo, hhllo, …) but not Hello.

The regex pattern (?i)h?llo would match hello or hallo as well as Hello or Hallo (and many more like heLLo or HELLO).

Useful Web-Sources about Regular Expressions

https://golang.org/pkg/regexp/syntax/