const regex = /(?<put_some_fieldname>S:\/.*)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<put_some_fieldname>S:\\\/.*)', 'gm')
const str = `7/31/18
8:15:01.000 PM
S:/PCTOOLS/085/CommLend/Comments/ad_hoc.ldb
S:/PCTOOLS/085/CommLend/Comments/romcomm.ldb
***
Script Information:
Script LdbFileCheckerWE run on Admin Server: SAT1MVMAP263 and creates log at location:D:/PCTOOL/Logs/LDB/LdbFileLogsWE.txt
host = SAT1MVMAP263 source = D:\\PCTOOL\\Logs\\LDB\\LdbFileLogsWE.txt sourcetype = auto_preprod_ldb_log
7/31/18
8:15:00.000 PM
2018/07/31 19:15:00
Hello Ally\\x96Hosting Windows Team,
Kindly refer below path,Server details and close below open user sessions:
Server Name: USPLZ1MVPFP001.NAO.GLOBAL.GMACFS.COM
S:/PCTOOLS/005/CommLend/Comments/romcomm.ldb
S:/PCTOOLS/061/CommLend/Comments/romcomm.ldb
S:/PCTOOLS/084/CommLend/Comments/romcomm.ldb`;
// 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