// include the latest version of the regex crate in your Cargo.toml
extern crate regex;
use regex::Regex;
fn main() {
let regex = Regex::new(r"(?m).*?(\w+).*\n?").unwrap();
let string = "• 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%)";
let substitution = "$1 ";
// result will be a String with the substituted value
let result = regex.replace_all(string, substitution);
println!("{}", 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 Rust, please visit: https://docs.rs/regex/latest/regex/