Safari Books Online is a digital library providing on-demand subscription access to thousands of learning resources.
Strings are a fundamental ingredient in almost every application. You’ll use string processing to validate user-supplied input, search a block of text for specific words or recurring patterns, and format numbers, dates, and times.
In the Microsoft .NET Framework, strings are based on the String class. The String class is far more than a simple array of characters—it also comes equipped with a full complement of methods for searching, replacing, and parsing text. The early recipes in this chapter (1.1 to 1.10) show how you can use this built-in functionality to accomplish common string manipulation tasks. Later recipes consider some slightly more involved techniques, including the StringBuilder class, which greatly increases the performance of repetitive string operations, and regular expressions, which provide a platform-independent syntax for specifying patterns in text. Regular expressions can be a daunting subject, and crafting your own expressions isn’t always easy. To get a quick start, you can use recipe 1.17, which includes an indispensable set of premade regular expressions that you can use to validate common types of data such as passwords, phone numbers, and e-mail addresses.