Searching Strings with Regular Expressions The System.String type itself offers some rudimentary searching methods, such as IndexOf , IndexOfAny , LastIndexOf , LastIndexOfAny , and StartsWith . Using these methods, you can determine if a string contains certain substrings and where. However, these methods quickly become cumbersome and are a bit too primitive to do any complex searching of strings effectively. Thankfully, the .NET Framework library contains classes that implement regular expressions (regex). If you’re not already familiar with regular expressions, I strongly suggest that you learn the regular-expression syntax and how to use it effectively. The regular-expression syntax is a language in and of itself. Excellent sources of information on the syntax include Mastering Regular Expressions, Third Edition , Jeffrey E. F. Friedl (Sebastopol, CA: O’Reilly Media, 2006) and the material under “Regular Expression Language Elements” within the MSDN documentation. The capabilities of the .NET regular-expression engine are on par with those of Perl 5 and Python. Full coverage of the capabilities of regular expressions with regard to their syntax is beyond the scope of this book. However, I’ll describe the ways to use regular expressions that are specific to the .NET Framework.