const regex = /(?<=<span>)(.|\n)*?(?=<\/span>)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=<span>)(.|\\n)*?(?=<\\\/span>)', 'gm')
const str = `<span>
Do not use hard returns to break lines; use the word wrap feature.
</span>
<span>
The
<strong>abstract paragraph</strong>
cannot exceed 250 words. A maximum of 2 tables and/or figures are acceptable. Deduct 50 words from the maximum word count for each included table or figure. Figures
should be no larger than 3.5 inches wide by 4.0 inches high, legible at these dimensions, and cropped to eliminate extra white space. Tables must fit and be legible
within a 3.5 inch column.
</span>`;
// 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