const regex = /\W\s(?<Item>[\w\s\dA-Za-z]+?)\s+?.+Price:/m;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('\\W\\s(?<Item>[\\w\\s\\dA-Za-z]+?)\\s+?.+Price:', 'm')
const str = `"🌎 Probably #Israel only! 🌎
✔ Alfawise WM01 Wireless Mouse
💰 Price: 1.99 USD (~1.73 EUR) ❗ 🔥 (Best in my DB: 1.99 USD)
💵 Code = GBZY07wm
🌐 Link: http://bit.ly/2EzJWCv
🔎 Current: \$1.99 | Average: \$2.22 | 7 records in DB | Price monitoring since 19.9.2018 🔎
More country-specific coupons: https://couponsfromchina.com/2018/05/11/ultimate-country-specific-gearbest-coupons-list-gearbest/"`;
// Reset `lastIndex` if this regex is defined globally
// regex.lastIndex = 0;
let m;
if ((m = regex.exec(str)) !== null) {
// 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