Skip to content

Regular Expressions

A regular expression is a specific search text, in which special strings are used in order to make it applicable to text patterns in a file. A regular expression consists of one or more non-empty branches (=strings). These branches are connected or separated by the character "|". Example: branch | branch | branch;

If a string within the text searched meets the criteria defined by a branch, an appropriate result is displayed.

Regular expression - meta-signDescription
* ? . | () [] + \ and string(s) to be searched forSearch for all characters (letters, figures, other) except * ? . | () [] + \ (=meta-signs or operators); the special function of the above signs is cancelled by putting a \ in front. Example: Search with a\*ctivity for a*ctivity.
.Instead of the . any character may occur in the result. Example: w.rd finds ward, w4rd, wgrd, word, etc.
[]One of the characters within the brackets must be contained in the result, but the characters within the brackets may not be combined in the result. Please note that the order of the characters searched is of no importance when using square brackets (in contrast to round brackets). Example: w[aeiou]rd finds ward, werd, wird, word, wurd but, for example, not waerd.
[^]The "caret - ^" within square brackets excludes the following string from the search result. Example: wo[^0-9]rd cannot find a result like wo3rd.
^The result contains those lines starting with the character (combination) following the caret. Example: ^word finds all lines starting with word.
$The result shows all lines ending with the character (combination) in front of the "$". Example: less$ finds all lines ending with less. If a line ends with less.$, the full stop must be cancelled by less \ .$.
()Round brackets serve the grouping of character (sequences). The search result refers to the expression within the brackets. Example: (wo)+rd finds wowoword or www wo rd, but not wooord!
|You can combine search criteria by describing several regular expressions. These branches are connected or separated by the character |. Example: (w.rd | less | .)s; a string is displayed if it meets the criteria of at least one branch, e.g. words, wards, lesss

The three following operators always refer to the character immediately preceding the operator:

Regular expression - meta-signDescription
?The character preceding the "?" occurs either once or not at all (? represents the quantity 0). Example: wo?rd finds the result wrd or word.
*The character preceding the "*" occurs either not at all (* represents the quantity 0) or up to an indefinite number of times. The search result for wo*rd is either wrd or word, woord, wooord etc.
+The character preceding the "+" occurs either once or up to an indefinite number of times. The search result for wo+rd is either word or woord, wooord, woooord, ....