Match Class and MatchCollection Class
Part of my 2008 study notes for exam 70-536 (.NET Framework 2.0).
Overview
- Contains the result of matches in 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
ArrayList Class
Resizeable, unordered, index-based collection. Suffers from boxing/unboxing when working with value types. Implements IEnumerator, allowing foreach…
BinaryReader Class and BinaryWriter Class
Used to read and write binary data from streams. Call the correct Read methods when using a BinaryReader.
BitArray Class
Contains an array of true/false values. Resizable through the Length property. Supports bitwise operations.



