const regex = new RegExp('(?i)Store number – ([\\d\\D]*)\\n.*StreetA – ([\\d\\D]*)\\n.*City – ([\\d\\D]*)\\n.*State_id – ([\\d\\D]*)\\n.*Postal Code – ([\\d\\D]*)\\n.*Store Name – ([\\d\\D]*)\\n.*Phone Number – ([\\d\\D]*)\\n.*Tax Rates.*\\n.*Tax table 1 – ([\\d\\D]*)\\n.*Tax table 2 – ([\\d\\D]*)\\n.*Tax table 3 – ([\\d\\D]*)\\n.*Tax table 4 – ([\\d\\D]*)\\n.*Tax table 5 – ([\\d\\D]*)\\n.*Artistree vendor – ([\\d\\D]*)\\n.*Store Group – ([\\d\\D]*)\\n.*Store Zone number – ([\\d\\D]*)', 'gm')
const str = `FP Team,
Please install the Live database for store 1384. The updates have been completed.
• Store number – 1384
• StreetA – 1275 York Rd, Ste 21A
• City – Gettysburg
• State_id – PA
• Postal Code – 17325-7565
• Store Name – Gettysburg, PA
• Phone Number – (717) 420-8200
• Tax Rates
o Tax table 1 – 6.0000%
o Tax table 2 – 0.0000%
o Tax table 3 – 0.0000%
o Tax table 4 – 0.0000%
o Tax table 5 – N/A
• Artistree vendor – Kernersville
• Store Group – US.201308
• Store Zone number – 2030`;
// 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