3 This syntax is a language in
and of itself, and full coverage of its capabilities is beyond the scope of this book. However,
we??™ll describe the ways to use regular expressions that are specific to the .NET Framework.
There are really three main types of operations for which you employ regular expressions.
The first is when searching a string just to verify that it contains a specific pattern, and if so,
where. The search pattern can be extremely complex. The second is similar to the first, except,
CHAPTER 9 n WORKING WITH STRINGS 185
3. See the Regular Expression page on Wikipedia at http://en.wikipedia.org/wiki/Regular_expression
for an introduction.
in the process, you save off parts of the searched expression. For example, if you search a
string for a date in a specific format, you may choose to break the three parts of the date into
individual variables. And finally, regular expressions are often used for search-and-replace
operations. This type of operation builds upon the capabilities of the previous two. Let??™s take a
look at how to achieve these three goals using the .NET Framework??™s implementation of regular
expressions.
Searching with Regular Expressions
As with the System.String class itself, most of the objects created from the regular expression
classes are immutable.
Pages:
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314