Csharp/C Sharp by API/System.Text.RegularExpressions/GroupCollection — различия между версиями
Admin (обсуждение | вклад) м (1 версия) |
|
(нет различий)
|
Версия 18:31, 26 мая 2010
GroupCollection.Index
<source lang="csharp"> using System; using System.Text.RegularExpressions; class GroupingApp {
static void Main(string[] args) { Regex r = new Regex("(i(n))g"); Match m = r.Match("Matching"); GroupCollection gc = m.Groups; Console.WriteLine("Found {0} Groups", gc.Count); for (int i = 0; i < gc.Count; i++) { Group g = gc[i]; Console.WriteLine("Found "{0}" at position {1}",g.Value, g.Index); } }
}
</source>
GroupCollection.Value
<source lang="csharp"> using System; using System.Text.RegularExpressions; class GroupingApp {
static void Main(string[] args) { Regex r = new Regex("(i(n))g"); Match m = r.Match("Matching"); GroupCollection gc = m.Groups; Console.WriteLine("Found {0} Groups", gc.Count); for (int i = 0; i < gc.Count; i++) { Group g = gc[i]; Console.WriteLine("Found "{0}" at position {1}",g.Value, g.Index); } }
}
</source>