const regex = /Host: (.*?)<br>/gu;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('Host: (.*?)<br>', 'gu')
const str = `<span style="font-weight: bold;"> Problem started at 15:14:06 on
2022.06.16<br>
Problem name: Site is Down!<br>
Host: worldbells.com<br>
Severity: Average<br>
Operational data: 100 %<br>
Original problem ID: <br>
</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