using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(\/?[A-Z][a-z]+(?:\s(?:[A-Z]['a-z]+)+))(?:\s+(lbw|not\sout|(c\.|st|run\sout)\s\(?(\w+)\)?))?(?:\s+((?:b\.\s)(\w+)))?\s+";
string input = @"David Warner lbw b. Hassan 19 16 4 0 118.8%
Joe Burns b. Morkel 73 149 16 0 49.0%
Asad Shafiq c. Rahane b. Morkel 22 38 5 0 57.9%
Yasir Shah not out 1 12 0 0 8.3%
Yasir Shah st Rahane 1 12 0 0 8.3%
Morne Morkel run out (Shah) 11 17 1 1 64.7%";
foreach (Match m in Regex.Matches(input, pattern))
{
Console.WriteLine("'{0}' found at index {1}.", m.Value, m.Index);
}
}
}
Please keep in mind that these code samples are automatically generated and are not guaranteed to work. If you find any syntax errors, feel free to submit a bug report. For a full regex reference for C#, please visit: https://msdn.microsoft.com/en-us/library/system.text.regularexpressions.regex(v=vs.110).aspx