const regex = /(?i),([^,]*),([^,]*),"ViewerURL"/;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?i),([^,]*),([^,]*),"ViewerURL"', '')
const str = `2015-10-07T08:59:28,42eba5da-2637-4df0-ad31-2b868a74fced,FMD4080N0W,HKGRANMC-06,xxx.xxx.com,lxxxxxx229,n/a,wfshell shell,ICA Seamless Host Agent,2c693e3b-087b-4ad5-9664-8647feb39989,,Windows,https://xxxxxx:4884/xxxxxx/SlideViewer.aspx?SessionID=42EBA5DA-2637-4DF0-AD31-2B868A74FCED&DisplayOnAir=false&lang=en&SSID=2C693E3B-087B-4AD5-9664-8647FEB39989
"FirstScreenshotTime","SessionId","ClientName","ServerName","DomainName","LoginName","UserName","ApplicationName","WindowTitle","ScreenshotID","Command","OS","ViewerURL"
`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// 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