Regex for Visual Studio Find and Replace reference

posted in: Uncategorized | 0

johnWeeGo.jpgIt is amazing how powerful and productive find and replace can be if you know the tricks of Regex in VS2005. Here are the main set:

Expression Syntax Description

Any character

.

Matches any single character except a line break.

Zero or more

*

Matches zero or more occurrences of the preceding expression, making all possible matches.

One or more

+

Matches at least one occurrence of the preceding expression.

Beginning of line

^

Anchors the match string to the beginning of a line.

End of line

$

Anchors the match string to the end of a line.

Beginning of word

<

Matches only when a word begins at this point in the text.

End of word

>

Matches only when a word ends at this point in the text.

Line break

\n

Matches a platform-independent line break. In a Replace expression, inserts a line break.

Any one character in the set

[]

Matches any one of the characters within the []. To specify a range of characters, list the starting and ending character separated by a dash (-), as in [a-z].

Any one character not in the set

[^…]

Matches any character not in the set of characters following the ^.

Or

|

Matches either the expression before or the one after the OR symbol (|). Mostly used within a group. For example, (sponge|mud) bath matches “sponge bath” and “mud bath.”

Escape

\

Matches the character that follows the backslash (\) as a literal. This allows you to find the characters used in regular expression notation, such as { and ^. For example, \^ Searches for the ^ character.

Tagged expression

{}

Matches text tagged with the enclosed expression.

C/C++ Identifier

:i

Matches the expression ([a-zA-Z_$][a-zA-Z0-9_$]*).

Quoted string

:q

Matches the expression ((“[^”]*”)|(‘[^’]*’)).

Space or Tab

:b

Matches either space or tab characters.

Integer

:z

Matches the expression ([0-9]+).

 

http://msdn2.microsoft.com/en-us/library/2k3te2cs(VS.80).aspx