Searching Strings with the Match and MatchCollection Classes

The Match class encapsulates information about a Regular Expressions pattern match—including a property to determine if the match was successful, the relative index into the string where the pattern was found (matched), and the matched value. This works by simply constructing a Regex object with the desired pattern and then calling the Regex class's Match method to return a Match object. The success or failure of the match can then be determined by evaluating the Match::Success Boolean property. For situations where a pattern might yield multiple matches, a collection object of type MatchCollection can be acquired via a call to the Regex::Matches method. As you might suspect, the

Get Extending MFC Applications with the .NET Framework now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.