|
|
 |

 |
|
Inside C#, Second Edition
|
|
|
Author
|
|
Tom Archer, Andrew Whitechapel
|
|
|
Pages
|
912
|
|
Disk
|
1 Companion CD(s)
|
|
Level
|
All Levels
|
|
Published
|
04/24/2002
|
|
ISBN
|
9780735616486
|
|
Price
|
$49.99
To see this book's discounted price, select a reseller below.
|
|
|
|
|
 |
|
|
Chapter 10: String Handling and Regular Expressions
10 String Handling and Regular Expressions
This chapter breaks down into two main sections: strings and regular expressions, each represented by one primary classString and Regex, respectivelyand a set of ancillary classes. However, there's a great deal of overlap between the two: in most situations, you have the option to use all string methods, all regular expression operations, or some of each. Code based on the string functionality tends to be easier to understand and maintain, while code using regular expressions tends to be more flexible and powerful.
We'll start by looking at the String class, some of its simple methods, and its range of formatting specifiers. We'll then look at the relationship between strings and other .NET Framework classesincluding Console, the basic numeric types, and DateTimeand how culture information and character encoding can affect string formatting. We'll also look at the StringBuilder support class and under the hood at string interning.
In the second part of this chapter, we'll look at the regular expression classes in the System.Text namespacemost notably Regex and its supporting classes, Match, Group, and Capture. We'll first examine how you can achieve the same results from either the String class or the Regex class and then move on to more sophisticated uses of regular expressions. We'll consider both pattern searching and string modifying through the set of Regex instance and static methods. We'll then see how RegexOptions modifies the behavior of the operation and finally peek under the hood to see how the system can compile regular expressions to assemblies.
Next
Last Updated: April 8, 2002
|