Skip to content

Regular expressions

Patrick Bruner edited this page Jul 10, 2025 · 1 revision

Here are the most important regular expressions you can use in the filter, search dialog and in the command line arguments for external tools. There are some more, but the author is too lazy to copy them all from the Microsoft MSDN pages (and probably it may be illegal). On the end of the page there's a link to the original regular expression documentation for .NET.

Character Classes

Pattern Description
[char_group] Any character of the group. Example: [abc] matches a, b, or c.
[^char_group] Any character not in the group. Example: [^abc] matches everything except a, b, or c.
[from_char-to_char] Characters in a range. Example: [a-z] matches all lowercase letters.
. Any character except \n. Note: . inside [] (like [.]) is literal.
\w Matches any word character: [a-zA-Z_0-9]
\W Matches any non-word character: [^a-zA-Z_0-9]
\s Whitespace character
\S Non-whitespace character
\d Decimal digit [0-9]
\D Non-decimal digit

Quantifiers

Pattern Description
* Zero or more matches
+ One or more matches
? Zero or one match
{n} Exactly n matches
{n,} At least n matches
{n,m} Between n and m matches
*? Lazy match: as few repeats as possible
+? Lazy match: as few repeats as possible, but at least one
?? Lazy match: zero if possible, or one

Escape Sequences

Pattern Description
\t Tab character
\r Carriage return
\n New line
\x20 ASCII character in hexadecimal (2 digits). Example: \x20 is a space
\\ Escape character. Use \ to escape the next character. Example: \* matches a literal *
\b In []: backspace character. Outside []: word boundary

Substitution Patterns (e.g., in Replace Operations)

Substitutions are used in replacement patterns.

Pattern Description
$number Substitutes the substring matched by the capturing group with that number (e.g., $1)
$$ Inserts a literal $
$& Inserts the entire match
`$`` Inserts all text before the match
$' Inserts all text after the match
$+ Inserts the last captured group
$_ Inserts the entire input string

Grouping and Capturing

Pattern Description
(subexpression) Captures the matched subexpression. Groups are numbered by the order of ( starting from 1. Group 0 always contains the full match.

The complete documentation of all RegEx options for .NET can be found on the Microsoft Learn pages: https://learn.microsoft.com/en-us/dotnet/standard/base-types/regular-expressions

πŸ› οΈ Functions
🧰 SDK
Clone this wiki locally