const regex = /[0-9]/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('[0-9]', 'gm')
const str = `WEBVTT
NOTE duration:"02:09:15.8840000"
NOTE language:en-us
NOTE Confidence: 0.881069481372833
d8d8fcb9-ccb1-41f2-a75e-0c3088e95dc2
00:00:01.720 --> 00:00:07.798
So we're going
to try to
NOTE Confidence: 0.881069481372833
a8f8cc83-48c4-4acc-881b-85b37c73b42c
00:00:07.798 --> 00:00:13.876
to use Microsoft
Teams next week,
NOTE Confidence: 0.881069481372833
d2738b5d-b7ee-4b58-8388-4b7524c3c563
00:00:13.876 --> 00:00:19.954
so will post
it as a
NOTE Confidence: 0.802268326282501
baab9c8e-f018-48a2-a355-b23eb29174e9
00:00:19.954 --> 00:00:25.728
teams meeting. If you've never
used prosoft teams before, it's
NOTE Confidence: 0.932209372520447
73231caa-7ae7-4046-acdf-c6691c7c3c41
00:00:25.728 --> 00:00:30.013
it's. Basically the same thing,
just a little more stable.
NOTE Confidence: 0.825244784355164
3ab6c4cb-9d70-4140-8356-c0f7c2316874
00:00:30.730 --> 00:00:35.224
Then they will put the link in
Quercus and send it out as an`;
// 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