const regex = /""".*?"""(*SKIP)(*FAIL)|(,)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('""".*?"""(*SKIP)(*FAIL)|(,)', 'gm')
const str = `c5604d659e4a4dee8f16d4449e3d94cd,1626656731,2021-07-18 19:05:31,,1289,5,0,3,2,0,1,1,,www.hp44clk.com,1,0,0.0,CPC,0.0,RPC,79545831,589aebf897e9c85c062871888fbdbb59,,,,,,0,,0,N/A,107.77.227.150,"""Mozilla/5.0 (iPhone; CPU iPhone OS 14_6 like Mac OS X) AppleWebKit/605.1.15 (KHTML, like Gecko) Version/14.1.1 Mobile/15E148 Safari/604.1""",en-us,,,,,,,iOS,14.6,Apple,,Mobile,en,Safari,,United States,Hawaii,Kailua,744,Att Mobility Llc,0,,Yes,No,No,0,AT&T Wireless USA,,,`;
// 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