const regex = /(?<=6.1.1 Необходимые)([.*\w\W\n]+)(?=и чрезвычайных ситуациях)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=6.1.1 Необходимые)([.*\\w\\W\\n]+)(?=и чрезвычайных ситуациях)', 'gm')
const str = ` 6.1.1 Необходимые Во время уборки используйте подходящие средства защиты и одежду. Не прикасаться к
действия общего поврежденным контейнерам или пролитому материалу, не надев соответствующей
характера при аварийных защитной одежды.
и чрезвычайных ситуациях
6.1.2 Средства Пользоваться непроницаемыми для пыли защитными очками, там, где существует
индивидуальной защиты опасность контакта с глазами. Надеть респиратoр с пылевым фильтрoм. Используйте
в аварийных ситуациях соответствующие химически стойкие перчатки. Обеспечить адекватную вентиляцию`;
// 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