const regex = /:?(\d+:\d+;)+\d+::/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp(':?(\\d+:\\d+;)+\\d+::', 'g')
const str = `[04:04:55] Morpheus Deathbrew > is this okay? it's cap stable <url=fitting:11978:14240;1:2032;1:31366;1:1447;2:2281;1:31952;1:14136;1:31378;1:2104;1:3608;4:12058;1:2488;6:29001;6::>He Dead :(</url>
[04:04:55] Morpheus Deathbrew > is this okay? it's cap stable <url=fitting:11978:14240;1:2032;1:31366;1:1447;2:2281;1:31952;1:14136;1:31378;1:2104;1:3608;4:12058;1:2488;6:29001;6::>He Dead :(</url>
Character Name > <url=fitting:11978:14240;1:31366;1:1447;2:31952;1:14136;1:31378;1:2104;2:3608;4:12058;1:31932;1:2488;6:29001;5::>He Dead :(</url> asdf asefase 351235125
`;
// 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