const regex = /(\b[A-ZА-Я](?:\w+[,;:’()-]? ){3,}\w{1,}[.!?])/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(\\b[A-ZА-Я](?:\\w+[,;:’()-]? ){3,}\\w{1,}[.!?])', 'gm')
const str = `Medically reviewed by Andrea Hodgson — Written by Susan York Morris — Updated on September 2, 2018
Introduction
Тест тест тест тест тест тест тест тест тест.
Kdenfjr - fkefkwfwf kljmlk lklkjol klmlmkl klkoik kjio.
Erectile dysfunction (ED) is a problem with getting and maintaining an erection that’s firm enough to have sexual intercourse. All men have trouble getting an erection from time to time, and the likelihood of this problem increases with age. If it happens to you often, though, you may have ED.
Viagra is a prescription drug that can help men with erectile dysfunction. For many people, romance means candlelight, soft music, and a glass of wine. The little blue pill, Viagra, can be part of this picture, but only if you drink small or moderate amounts of alcohol.`;
// 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