
84
|
Chapter 3, Navigating Visual Studio
#19 Search for Patterns in Your Files
HACK
HACK
#19
Search for Patterns in Your Files Hack #19
Unleash the power of regular expressions to make everyday searches and
Find and Replace operations more powerful.
Regular expressions are an extremely versatile text-matching language that
gives you incredible power when searching your documents and when used
with replace operations, can greatly assist with repetitive changes to blocks
of code.
Searching
The basic regular expression search is easily done. You simply open the Find
dialog through the Edit
➝ Find and Replace ➝ Find menu or with Ctrl-F
(Edit.Find). Enable regular expression searching by ensuring the Use check-
box is selected and the drop-down list has Regular Expressions selected, as
shown in Figure 3-12.
In Visual Studio 2005, the Find dialog has changed. To enable regular
expressions searching, you will need to expand the Find Options section of
the dialog. Figure 3-13 shows the new Find dialog with the Options section
expanded.
Enter your regular expression into the Find What text box and click on Find
Next. The next match of your expression will be found in the document. As
with normal matches, clicking Find Next again will find the next match. The
next step is to learn the regular expression (also known as regex or regexp)
syntax. Searching will never be the same.
Figure 3-11. Incremental search