From 209de180e98affa6e2eee9e6d0faca99d69ca8bd Mon Sep 17 00:00:00 2001 From: Maple Nebel Date: Wed, 1 Jul 2026 19:56:34 +0200 Subject: [PATCH] fix regex --- Cargo.toml | 2 +- src/error_codes.rs | 5 ++++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/Cargo.toml b/Cargo.toml index 4894057..6ebb48c 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,7 +10,7 @@ debug = "none" debug-assertions = false strip = true panic = "abort" -lto = true +# lto = true diff --git a/src/error_codes.rs b/src/error_codes.rs index 1b3aac4..e56971b 100644 --- a/src/error_codes.rs +++ b/src/error_codes.rs @@ -56,11 +56,14 @@ impl Default for ErrorInfo { } static ERROR_CODE_REGEX: Lazy = - Lazy::new(|| Regex::new("(?<=(^| ))\\d\\d\\d-\\d\\d\\d\\d(?=($| ))").expect("invalid regex")); + Lazy::new(|| Regex::new("\\b\\d\\d\\d-\\d\\d\\d\\d\\b").expect("invalid regex")); +static WORD_BOUNDARY_START: Lazy = Lazy::new(|| Regex::new("^\\b").expect("invalid regex")); +static WORD_BOUNDARY_END: Lazy = Lazy::new(|| Regex::new("\\b$").expect("invalid regex")); pub struct ErrorCodeHandler; fn create_error_explain_message(str_code: &str, expanded: bool) -> Option { + let str_code = str_code.trim(); let Ok(category) = str_code[0..3].parse() else { return None; };