using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(\b\d\d[-|\s]\d\b)\s(\b[a-z]+\b)";
string input = @"57-61 P D DeS, 62-4 Dodge 880, 57-64 C
39-56 P, D, 40-52 DeS, 53-4 DeS except wagon, 55-6 DeS Fireflite, 55-6 DeS Firedome except wagon, 40-52 C 6 cyl, 53-6 C except Imp, wagon, LWB
57-8 C, I, 60 with model E AC, PP2, PD4, High Performance, PD1, PD2, PS1, PS3, PC1, PC2, PC3, PY1, 61 with model F AC RP2 Hipo, DeS, C, Imp, 61 Dart 6, 62 P, D 6 without air, 62 C 300 and Newport, 62 P, D with 361, 63 P, D 6 62 P Valiant, Lancer with model G AC, 64 Val, Dart 273, 318, VD2 361, 383 with air and towing, 65 P, D all with 273, 318 and no air, 63-8 DT C500 with 318 and air, 69 P, D exc. Belv. Cor, 70-72 B,J,R,W with 318, 73 B,J,R,W,P,D with 318, 360";
RegexOptions options = RegexOptions.Multiline | RegexOptions.IgnoreCase;
foreach (Match m in Regex.Matches(input, pattern, options))
{
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