
Match Class and MatchCollection Class
Part of my 2008 study notes for exam 70-536 (.NET Framework 2.0).
Overview
- Contains the results of matching a regex.
Examples
Scanning Text
string input = "Hello world! Hello!";
string regex = "(?<1>ll)";
for (Match m = Regex.Match(input, regex); m.Success; m = m.NextMatch())
{
Console.WriteLine(m.Groups[1].Index + ": " + m.Groups[1]);
}
Formatting Text
string input = "[link=\"http://blog.cumps.be/starting-exam-70-536-study/\"]Starting Exam 70-536 Study[/link]";
string regex = @"\[link=""(?<link>((.|\n)*?))""\](?<text>((.|\n)*?))\[\/link\]";
Console.WriteLine(Regex.Match(input, regex).Result("${text}: ${link}"));
You May Also Like

Exam 70-536 Study Notes
My study notes for Microsoft exam 70-536: .NET types, collections, generics, I/O, serialization and more, with C# examples.

Starting Exam 70-536 Study
After a burnout, I'm putting my own project on hold to study for Microsoft exam 70-536.

Design Patterns - Proxy Pattern
The Proxy Pattern, and the last article in the design patterns series, now that I've finished reading Head First Design Patterns.



