const regex = /\b(?!TSPU\b)[A-Z]{4,}(?:(?:\s+\w\.)?\s+\w+)?/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\b(?!TSPU\\b)[A-Z]{4,}(?:(?:\\s+\\w\\.)?\\s+\\w+)?', 'gm')
const str = `JINA L. CHOI (NY Bar No. 2699718)
ERIN E. SCHNEIDER (Cal. Bar No. 216114) schneidere@sec.gov
MONIQUE C. WINKLER (Cal. Bar No. 213031) winklerm@sec.gov
JASON M. HABERMEYER (Cal. Bar No. 226607) habermeyerj@sec.gov
MARC D. KATZ (Cal. Bar No. 189534) katzma@sec.gov
JESSICA W. CHAN (Cal. Bar No. 247669) chanjes@sec.gov
RAHUL KOLHATKAR (Cal. Bar No. 261781) kolhatkarr@sec.gov
The Investor Solicitation Process Generally Included a Face-to-Face Meeting, a Technology Demonstration, and a Binder of Materials [...]
TSPU or taken
TSPU or the
TSPU only
TSPU was
TSPU and`;
// 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