const regex = new RegExp('(?<=by\\n)\\w.+', 'gm')
const str = `MIT Sample:
SOME ASPECTS OF RADIATION INDUCED NUCLEATION IN WATER
by
Chih-Ping Tso
B.Tech., Loughborough University of Technology, United Kingdom
(1968)
Submitted in Partial Fulfillment of
the Requirements for the Degree of
Master of Science
at the
Massachusetts Institute of Technology
August 1970
Signature of Author
Department of Nuclear Engineering
Certified by
Thesis Supervisor
Accepted by
Chairman, Departmental Committee
Archives on Graduate Students
MASS. INST. TECH.
SEP 21 1970
LIBRARIES
----------------------------------------------
Virginia Tech Sample:
FORMATTING VARIABLES AND TYPEFACE VARIATIONS
OF
DOT-MATRIX PRINT AND THEIR EFFECT
ON
READING COMPREHENSION AND READING SPEED
by
James A. Holmes
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 EDUCATION
in
Vocational and Technical Education
March, 1986
Blacksburg, Virginia`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
while ((m = regex.exec(str)) !== null) {
// This is necessary to avoid infinite loops with zero-width matches
if (m.index === regex.lastIndex) {
regex.lastIndex++;
}
// The result can be accessed through the `m`-variable.
m.forEach((match, groupIndex) => {
console.log(`Found match, group ${groupIndex}: ${match}`);
});
}
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 JavaScript, please visit: https://developer.mozilla.org/en/docs/Web/JavaScript/Guide/Regular_Expressions