
Professional Visual Studio 2005 (2006) [eng]
.pdf



Regular Expressions
Regular expressions are a great way to retrieve a set of matches for complex search criteria, but they’re underused because they can be quite complex and appear almost unintelligible to a lot of developers. With Visual Studio 2005, regular expressions are now not only usable in the normal program code, but also featured in other areas of the environment such as the Find and Replace dialog.
To help more programmers understand how to use them, this chapter introduces regular expressions and shows how they can be used in different situations. It discusses the particular implementation of regular expressions in Visual Studio 2005, along with descriptions of the major components of regular expression syntax so you can begin to build your own expressions confidently regardless of the situation.
At their core, regular expressions are a series of pattern-matching strings that use an extensive set of pattern constructs to control how strings of text can be matched. The character patterns can be used to find and then extract, replace, or remove substrings within large blocks of text, and are used often to extract information from large files with a defined syntax, such as HTML pages or even XML files and header information on e-mails.
Visual Studio 2005 provides an implementation of regular expressions through its use of the .NET Framework’s System.Text.RegularExpressions namespace, which includes several members that can be used in your code to perform the various functions of the regular expression engine using typical programming practices. Note that while the regular expression engine in Visual Studio is extensive, there may be differences between its implementation and that of other languages that use regular expressions, such as PHP or awk. In addition, the regular expressions that can be built in the Find and Replace dialog are a subset of the full set of functionality. Only syntactical elements appropriate in the context of finding and replacing text in files are available.





