using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"-\n([^(]+)(\(\d\))[|]([^-]+)";
string input = @"
--------------------------------------------------------------------------------
PHYS 11A GEN PHYS-MECHANICS (4)|NOT ARTICULATED
--------------------------------------------------------------------------------
PHYS 11B GEN PHYS-HEAT,LIGHT,SOUND (4)|NOT ARTICULATED
--------------------------------------------------------------------------------
PHYS 11C GEN PHYS-ELECT,MAG,MOD (4)|NOT ARTICULATED
--------------------------------------------------------------------------------
MATH 30 CALCULUS I (4)|MATH 180 Single Variable (4)
| Calculus I
--------------------------------------------------------------------------------
MATH 31 CALCULUS II (4)|MATH 185 Single Variable (4)
| Calculus II
--------------------------------------------------------------------------------
MATH 32 CALCULUS III (4)|MATH 280 Intermediate Calculus (4)
--------------------------------------------------------------------------------
MATH 45 DIFFERNTL EQUATN SCI+ENGR (3)|MATH 295 Differential Equations (3)
| ";
RegexOptions options = RegexOptions.Multiline;
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