const regex = /Connection reset.*?\b([^ .]+\.xls)\b/g;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('Connection reset.*?\\b([^ .]+\\.xls)\\b', 'g')
const str = `ava.net.SocketException: Connection reset at java.net.SocketInputStream.read(SocketInputStream.java:197) at jcifs.netbios.SessionServicePacket.readPacketType(SessionServicePacket.java:68) at jcifs.netbios.NbtSocket.connect(NbtSocket.java:107) at jcifs.netbios.NbtSocket.(NbtSocket.java:68) at jcifs.smb.SmbTransport.ensureOpen(SmbTransport.java:275) at jcifs.smb.SmbTransport.send(SmbTransport.java:602) at jcifs.smb.SmbTransport.negotiate(SmbTransport.java:847) at jcifs.smb.SmbTree.treeConnect(SmbTree.java:119) at jcifs.smb.SmbFile.connect(SmbFile.java:790) at jcifs.smb.SmbFile.connect0(SmbFile.java:760) at jcifs.smb.SmbFile.queryPath(SmbFile.java:1149) at jcifs.smb.SmbFile.exists(SmbFile.java:1232) at com.ssc.faw.util.SmbFileOperator.copyFile(Unknown Source) at com.ssc.faw.newnav2faw.FundList.checkFiles(Unknown Source) at com.ssc.faw.newnav2faw.FundList.buildList(Unknown Source) at com.ssc.faw.newnav2faw.Process.buildFundList(Unknown Source) at com.ssc.faw.job.NavToFaw.runNav2Faw(Unknown Source) at com.ssc.faw.job.NavToFaw.runNav2Faw(Unknown Source) at com.ssc.faw.job.NavToFaw.runJob(Unknown Source) at com.ssc.faw.job.NavToFaw.main(Unknown Source) [WARN ] 2015-05-05 21:02:26,383 Caught an Exception for file \\ac_asd_2.my_web.com\\global\\nvice\\alert\\ filename abcd123.xls continuing to process other funds 0 : null jcifs.smb.SmbException: An error occured sending the request.`;
// 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