const regex = /^((?:[^;<>]+;)*)(?:[^;]*(?:<|>)[^;]*;)*([^;<>]+)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)$/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^((?:[^;<>]+;)*)(?:[^;]*(?:<|>)[^;]*;)*([^;<>]+)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)(?:;[^;]*(?:<|>)[^;]*)*((?:;[^;<>]+)*)$', 'gm')
const str = `prov=b6a9a797-88de-95cf-705f-f04475ea4d8a; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _gid=GA1.2.19039273<28.1568202810; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; _ga=GA1.2.175<2530920.1564494>781; acct=t=YAiQ2RXtOBOG1Pf5UnKFxWZ%2bcINrjVde&s=%2btpIj7pF1GMoTVFuiDTS95VXolHih4l%2f; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499;_ym_uid=1565792005592706499;_ga=GA1.2.175<2530920.1564494>781;_ga=GA1.2.175<2530920.1564494>781;_ga=GA1.2.175<2530920.1564494>781;_ga=GA1.2.175<2530920.1564494>781;_ga=GA1.2.175<2530920.1564494>781;_ga=GA1.2.175<2530920.1564494>781; __gads=ID=fbdbf646c4f1b756:T=1564494781:S=ALNI_MaF9--jX-1UcW8INO5Pg9oENCXPJA; __qca=P0-1424341845-1564494781627; _ym_uid=1565792005592706499; _ym_d=1565792005; cc=e5a3d35ac7064d5caae23af2ce2caca0; superSecretTrackingCookie2=4efca328-421c-42e0-9426-96fbbb61cc51; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499;_gid=GA1.2.19039273<28.1568202810; acct=t=YAiQ2RXtOBOG1Pf5UnKFxWZ%2bcINrjVde&s=%2btpIj7pF1GMoTVFuiDTS95VXolHih4l%2f; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499;_gid=GA1.2.19039273<28.1568202810;_gid=GA1.2.19039273<28.1568202810;_gid=GA1.2.19039273<28.1568202810;_gid=GA1.2.19039273<28.1568202810;_gid=GA1.2.19039273<28.1568202810;_gid=GA1.2.19039273<28.1568202810; acct=t=YAiQ2RXtOBOG1Pf5UnKFxWZ%2bcINrjVde&s=%2btpIj7pF1GMoTVFuiDTS95VXolHih4l%2f; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499; _ym_uid=1565792005592706499
`;
// 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