
88
|
Chapter 3, Navigating Visual Studio
#19 Search for Patterns in Your Files
HACK
character $ matches the end of line, so the pattern ^a$ will match only if a is
the only character on a line.
Escaping characters. We have now discussed several different types of spe-
cial characters that are used to designate parts of a regular expression. If you
want to match those characters literally, you need to tell the regular expres-
sion engine to not interpret them as special portions of an expression. For
example, if you wish to match the character
[, you need to escape it with a
backslash and use
\[ in the expression.
Example expressions. Table 3-2 and Table 3-3 display a few example expres-
sions to show some of the flexibility of the syntax.
Regular Expressions in Your Code
The .NET Framework includes classes in the System.Text.Regular-
Expressions
namespace that allow you to include functionality using regular
expressions in your code. Unfortunately, the regular expression syntax
Microsoft uses inside of the Visual Studio IDE differs from the syntax used
by the .NET regular expression interpreter. Much of the syntax is identical;
however, many of the character sets and characters indicating the type of
expression or tagged expressions for replacement are different. It is also
important to note that by default the .NET regular expression classes are
case sensitive in their matching.
For in-depth coverage