const regex = /.*?(\w+).*\n?/gm;
// Alternative syntax using RegExp constructor
// const regex = new RegExp('.*?(\\w+).*\\n?', 'gm')
const str = `• BTC ⇒ 59982.00 USD (-6.38%)
• ETH ⇒ 4219.78 USD (-7.94%)
• BNB ⇒ 581.00 USD (-8.59%)
• CAKE ⇒ 16.78 USD (-9.35%)
• BAKE ⇒ 1.880000 USD (-11.42%)
• GRT ⇒ 0.921331 USD (-11.18%)
• LINK ⇒ 29.19 USD (-10.42%)
• DOT ⇒ 40.76 USD (-9.92%)
• XRP ⇒ 1.080000 USD (-8.26%)
• ENJ ⇒ 2.850000 USD (-6.82%)
• SOL ⇒ 221.16 USD (-6.81%)
• DOGE ⇒ 0.236049 USD (-8.49%)
• PROM ⇒ 16.94 USD (-7.29%)
• MATIC ⇒ 1.540000 USD (-9.23%)
• VET ⇒ 0.146540 USD (-10.92%)
• ADA ⇒ 1.880000 USD (-7.45%)
• SHIB ⇒ 0.000049 USD (-10.75%)
• XTZ ⇒ 5.220000 USD (-8.97%)
• ONE ⇒ 0.251386 USD (-12.99%)
• ALGO ⇒ 1.690000 USD (-10.67%)`;
const subst = `$1 `;
// The substituted value will be contained in the result variable
const result = str.replace(regex, subst);
console.log('Substitution result: ', result);
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