using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"^([^:(,]*)\b";
string input = @"Boston (Boston University, Boston College, Bos...
Bridgewater (Bridgewater State College)[2]
Cambridge (Harvard University, Massachusetts I...
Chestnut Hill (Boston College)
The Colleges of Worcester Consortium:
Dudley (Nichols College)
Faribault, South Central College
Mankato (Minnesota State University, Mankato),...
Marshall (Southwest Minnesota State University...
Moorhead (Minnesota State University, Moorhead...
Morris (University of Minnesota Morris)[2]
Northfield (Carleton College, St. Olaf College...
North Mankato, South Central College
St. Cloud (St. Cloud State University, The Col...
St. Joseph (College of Saint Benedict)[2]
St. Peter (Gustavus Adolphus College)[2]";
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