Ok(parse_from_lines(&stripped_lines, curr_count, bot_user))
}
+lazy_static! {
+ static ref LINE_PATTERN: fancy_regex::Regex = fancy_regex::Regex::new(
+ "^(?P<v>v)?(?P<neg>-)?(?P<num>[0-9]+((?P<sep>[,. \u{2009}]|, )[0-9]+((?P=sep)[0-9]+)*)?)"
+ ).unwrap();
+}
+
fn parse_from_lines(lines: &[impl Borrow<str>], curr_count: Option<Count>, bot_user: &str) -> ParsedUpdate {
let command = lines.iter().find_map(|l| parse_command(l.borrow(), bot_user));
} else {
// look for groups of ASCII digits (as many as possible) separated by a uniform separator
// from the valid set
- let pattern = fancy_regex::Regex::new(
- "^(?P<v>v)?(?P<neg>-)?(?P<num>[0-9]+((?P<sep>[,. \u{2009}]|, )[0-9]+((?P=sep)[0-9]+)*)?)"
- ).unwrap();
- let match_result = pattern
- .captures(lines[0].borrow())
+ let match_result =
+ LINE_PATTERN.captures(lines[0].borrow())
.with_context(|| format!("parsing line {:?}", lines[0].borrow()))
.unwrap();
if let Some(ref match_) = match_result {