const regex = new RegExp('Duration:\\s{1}(\\d+?):(\\d+?):(\\d+\\.\\d+?),', 'mg')
const str = ` Metadata:
major_brand : isom
minor_version : 0
compatible_brands: mp41avc1
creation_time : 2017-02-01T11:29:03.000000Z
playback_requirements: QuickTime 6.0 or greater
playback_requirements-eng: QuickTime 6.0 or greater
encoder : vlc 2.2.4 stream output
encoder-eng : vlc 2.2.4 stream output
Duration: 00:00:12.52, start: 0.000000, bitrate: 3597 kb/s
Stream #0:0(eng): Video: h264 (High) (avc1 / 0x31637661), yuv420p, 1280x720 [SAR 1:1 DAR 16:9], 3475 kb/s, 21.57 fps, 23.98 tbr, 1000k tbn, 47.95 tbc (default)
Metadata:
creation_time : 2017-02-01T11:29:03.000000Z
handler_name : VideoHandler
Stream #0:1(jpn): Audio: aac (LC) (mp4a / 0x6134706D), 44100 Hz, stereo, fltp, 128 kb/s (default)
Metadata:
creation_time : 2017-02-01T11:29:03.000000Z
handler_name : SoundHandler`;
// 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