const regex = new RegExp('^(.{2})(.{14}).{14}(.{8})(.{8})(.{20})(.{8})(.{1})(.{10}).{2}.{2}(.{2})(.{14}).{10}.{5}(.{16})(.{3})(.{18}).{15}.{15}.{6}.{6}.{2}.{3}.{18}.{10}(.{2}).{3}.{32}.{2}(.{10})(.{15}).{38}.{5}.{5}.{5}.{5}.{5}.{5}(.{16})(.{16})(.{20})(.{3})(.{3})(.{2})(.{20})(.{5})(.{15})(.{10}).{3}.{3}(.{2})(.{24})(.{3})(.{20})(.{2}).{24}(.{6}).{6}.{10}(.{3}).{3}.{3}(.{3})(.{3})(.{5})(.{3})(.{2}).{2}(.{5}).{2}.{20}.{5}.{20}.{2}.{3}.{2}.{5}.{325}(.{14}).{3}.{24}.{25}.{20}.{1}.{1}.{2}.{5}.{3}.{3}.{3}.{6}.{4}.{3}(.{5})(.{5})(.{3})(.{1})(.{3})', 'gm')
const str = `2422072021115242 GU32120300002689543200710020 489346250700918BE0D011 0022072021114833700918BE0D1 04D10790201AEA005 543200710020 1 5 543200310050 100 0 5 5491127654295 1 0 22072021114834 65535 655356553565535655356553565535 3 0 X700
`;
// 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