using System;
using System.Text.RegularExpressions;
public class Example
{
public static void Main()
{
string pattern = @"(degree(s)? of)(\n?|.+?)(\w.+|\w?.+\n.+)";
string input = @"MIT Sample:
AN EXPERIMENTAL INVESTIGATION OF
OIL SPREADING OVER WATER
by
Walter Suchon
Submitted in Partial Fulfillment
of the Requirements for the
degrees of
bachelor of science
and
Master of Science
at the
MASSACHUSETTS INSTITUTE OF TECHNOLOGY
April, 1970
Signature of Author
Department of Mechanical Engineering
Certified by.......
Thesis Supervisor
Accepted by
Chairman, Departmental Committee on Graduate Students
Archives
MASS INST. TECH.
SEP 10 1970
LIBRARIES
--------------------------------------------------------------
Virginia Tech Sample:
FUNDAMENTAL ADHESIVE STUDIES OF BLOCK COPOLYMERS
by
Margaret Mary Sheridan
Dissertation submitted to the Faculty of the
Virginia Polytechnic Institute and State University
in partial fulfillment of the requirements for the degree of
Doctor of Philosophy
in
Chemistry
APPROVED:
T.C. Ward, Chairman
D.W. Dwight M.A. Oglioruso
J.E. McGrath J.P. Wightman
October, 1985
Blacksburg, Virginia";
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