const regex = /SoapWriter\.\d+ (?:- )?\[[0-9a-z]* [0-9a-z]*\] - (?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})? - ((?:.|\n|\r)*)/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('SoapWriter\\.\\d+ (?:- )?\\[[0-9a-z]* [0-9a-z]*\\] - (?:[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12})? - ((?:.|\\n|\\r)*)', 'gm')
const str = `2021-02-25 14:06:25,810 [http-bio-8080-exec-70] INFO com.example.SoapWriter.27 - [7fbe6d227aa053b9 7fbe6d227aa053b9] - - <?xml version="1.0" encoding="UTF-8"?><soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"><soapenv:Body><processSync xmlns="urn:soap"><in0><?xml version="1.0" encoding="UTF-8"?><ESROrder xmlns="http://www.example.com/xsd/sea" xmlns:icp="http://www.atis.org/obf/wir/wicis5/schemas">
<OrderDetails>
<RequestDetails>
<CustomerName>example</CustomerName>
<SupplierName>example</SupplierName>
<OrderType>example</OrderType>
<OrderSubtype>example</OrderSubtype>
<Event>new</Event>
</in0></processSync></soapenv:Body></soapenv:Envelope>`;
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