Refactor number parsing regex
authorJakob Cornell <jakob+gpg@jcornell.net>
Sat, 30 Sep 2023 20:32:11 +0000 (15:32 -0500)
committerJakob Cornell <jakob+gpg@jcornell.net>
Sat, 30 Sep 2023 20:47:54 +0000 (15:47 -0500)
fancy_regex doesn't support disabling Unicode, so switch to explicitly matching ASCII digits.

sharedmodel/src/update_parse.rs

index 9c0c8eb71fc168be5029ad8edc1bd5d7843d71ad..758a5af64830bd89cd9025660e33c2255b5c7e2d 100644 (file)
@@ -152,7 +152,7 @@ fn parse_from_lines(lines: &[impl Borrow<str>], curr_count: Option<Count>, bot_u
                // 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(
-                       "(?-u)^(?P<v>v)?(?P<neg>-)?(?P<num>\\d+((?P<sep>[,. \u{2009}]|, )\\d+((?P=sep)\\d+)*)?)"
+                       "^(?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())