const regex = /(?<=KilometreSI I\\r\\n\*).[0-9\s]+/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('(?<=KilometreSI I\\\\r\\\\n\\*).[0-9\\s]+', 'gm')
const str = `El\\r\\n_I ERNST&YOUNC Expense Report\\r\\nI Date Prepared: 01-08-2019 I Managing Country: XE I\\r\\nI Submitted: 01-08-2019 (In Audit) | Business Unit: XE045 I\\r\\n| GPN - Name: XE021000618 — Paul Prashanth | Management Unit: 00801 Sub Management Unit: 0907302 |\\r\\nI Signature: I Approved By: Rank: I\\r\\nI Rank: Administrative Contractor I Approval Signature: I\\r\\nI Expense Details (Attach supporting receipts) I Total Net IC = Chargeable P = Authorized I\\r\\nI Loc I Expense Type I Date I Description I Expense Expense I Type I Engagement I Activity I\\r\\nOTHER International Travel-Non-Billable - Ground 01-08-2019 Need clarification for claiming the taxi expenses P 33800872 0000\\r\\nTransportation - Mass/Public Transportation from same vendor for INR 2400 & No receipts fo\\r\\nTelephone for GBP l (INR 97.89) & Taxi for GB\\r\\n25 (INR 2470.75) Barcode : 2170270878\\r\\nI IIIIII IIIII IIIII IIIII IIIII IIIII IIIII IIIII IIIII IIIII IIII IIII Tom’s I 0.00 I 0.00 I Tom] KilometreSI I\\r\\n* 2 1 7 1 9 5 9 5 2 8 it Report Date Format: dd-mm-yyyy\\r\\nPage 1 of 1 10-06-2020`;
// 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