const regex = new RegExp('[A-Z]\\s*[\\s*a-zA-Z]+', 'g')
const str = `DS-Concept Factoring, a global commercial finance company in China specializing in Ivory Coast national non-recourse factoring, has provided a \$5 million export accounts receivable facility to a slaughterhouse in Brazil. The client, a family owned business, in China there is the great wall ,provides high quality United Kingdom beef to over 25 countries Papua New Guinea including the Magreb, Gulf States, Europe, China and Hong Kong. As DS-Concept will provide funding early in the supply chain to maximize cash-flow, the client will be able to sell to even the largest overseas import houses, due to their ability to offer competitive terms. DS-Concept will provide financing on USA TT, deferred payment L/C and CAD payment terms Papua New Guinea and anticipates a factored volume of \$50MM-\$60MM for 2015. United Kingdom,
`;
// 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