const regex = /^[\dT:\.+-]+\s(?:aabvabcw74|aaxptac103).def.co.uk/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('^[\\dT:\\.+-]+\\s(?:aabvabcw74|aaxptac103).def.co.uk', 'gm')
const str = `2017-04-24T09:20:01.687387+00:00 aabvabcw74.def.co.uk hostd-probe:
2017-04-14T15:18:34.727042+00:00 Fri Apr 14 15:18:34 2017 aalesxbs029.def.co.uk lacp: DEBUG]:147, Recv signal 15, LACP service is about to stop
2017-04-24T09:20:01.687387+00:00 hostd probing is done. aabvabcw74.def.co.uk hostd-probe:
2017-04-24T20:53:29.334348+00:00 10.199.6.5 .def.co.uk aabvabcs15.def.co.uk Fdm: sslThumbprint>95:43:64:71:A3:60:D8:17:C8:6F:68:83:92:CE:E4:3B:53:4E:1D:AD10.199.6.5a2:0e:09:01:0a:00a2:0e:09:01:0b:01/vmfs/volumes/b01f388c-aaa4889f/vmfs/volumes/6ad2d8d7-86746df14435.5.03568722host-619286aabvabcs16.def.co.uk
2017-04-24T09:20:01.687387+00:00 aaxptac103.def.co.uk hostd-probe:`;
// 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