// 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"(^|[+-]?\d+\.\d*)$").unwrap();
let string = "TICKER|LAST_UPDE|PX_LAST
EE0002M Index|20211231|-0.58814
US0002M Index||
USB3MAY Index|20220502|0.8x9
SOFRRATE Index|20220505|c0.79
FEDL01 Index|20220505|0.83
US0001M Index|2022050|0.84486
FDTR Index|20220505|1
US0003M Index|20220505|1.37071
PRIME Index|20220505|4
TICKER|LAST_UPDATE|PX_LAST
EE0002M Index|20211231|-0.58814
US0002M Index|20211231|0.1525
USB3MAY Index|20220502|0.89
PRIME Index|20220503|3.5
SOFRRATE Index|20220504|0.3
FEDL01 Index|20220504|0.33
US0001M Index|20220504|0.84514
FDTR Index|20220504|0.5
US0003M Index|20220504|1.40614
";
// result will be a tuple containing the start and end indices for the first match in the string
let result = regex.captures(string);
let (start, end) = match result {
Some((s, e)) => (s, e),
None => {
// ...
}
};
println!("{}", &string[start, end]);
}
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/