Regular expressions
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
[char_group ] |
Any char of the group. E.g. [abc] will find a, b or c. |
[^ char_group] |
A char not contained in the group. [^abc] will find all but a, b or c |
[from_char-to_char] |
Chars contained in the range. [a-z] will find all lowercase letters. |
. |
Any char but \n. Note: a . in a character group ([.]) is a literal, not a placeholder for 'any char'. |
\w |
same as [a-zA-Z_0-9] |
\W |
same as [^a-zA-Z_0-9] |
\s |
Space |
\S |
No Space |
\d |
Decimal digit |
\D |
No decimal digit |
Quantifiers
* |
Zero or more matches |
+ |
One or more matches |
? |
Zero or one matches |
{n} |
Exactly n matches |
{n,} |
At least n matches |
{n,m} |
n to m matches |
*? |
First match that consumes as few repeats as possible |
+? |
As few repeats as possible, but at least one |
?? |
Zero repeats if possible, or one |
Escapes
\t |
Tab |
\r |
Carriage return |
\n |
New line |
\x20 |
ASCII char in hex notation (2 digits) |
\ |
Use \ to escape the following character. For example \* |
\b |
When in [] it's a backspace char. Otherwise a word boundary. |
Grouping
( subexpression ) |
Captures the matched subexpression. Captures using () are numbered automatically based on the order of the opening parenthesis, starting from one. The first capture, capture element number zero, is the text matched by the whole regular expression pattern. |
Substitutions
Substitutions are used in replacement patterns.
$number |
Substitutes the last substring matched by group number number (decimal). |
$$ |
Substitutes a $ literal. |
$& |
Substitutes the match itself. |
$` |
Substitutes all the text of the input string before the match. |
$' |
Substitutes all the text of the input string after the match. |
$+ |
Substitutes the last group captured. |
$_ |
Substitutes the entire input string. |
The complete documentation of all RegEx options for .NET can be found on the Microsoft MSDN pages:
http://msdn.microsoft.com/en-us/library/az24scfc(VS.80).aspx