Improve regex compatibility

Neither of the changed regexes were accepted by the regex crate, which thought the fmt regex looked like an invalid repetition count (e.g. "a{5}") and which doesn't support negative lookahead.
This commit is contained in:
Oliver Hamlet
2025-03-25 22:02:34 +00:00
parent e61aeabfbb
commit ded5f34b7f
2 changed files with 3 additions and 3 deletions
+1 -1
View File
@@ -326,7 +326,7 @@ impl TryFrom<&MarkedYaml> for Message {
if !subs.is_empty() {
static FMT_REGEX: LazyLock<Regex> = LazyLock::new(|| {
Regex::new(r"{(\d+)}").expect("hardcoded fmt placeholder regex should be valid")
Regex::new(r"\{(\d+)\}").expect("hardcoded fmt placeholder regex should be valid")
});
for mc in &mut content {
+2 -2
View File
@@ -415,9 +415,9 @@ fn extract_version(description: &str) -> Result<Option<String>, Box<fancy_regex:
// The string below matches the range of version strings supported by
// Pseudosem v1.0.1, excluding space separators, as they make version
// extraction from inside sentences very tricky and have not been seen "in
// the wild". The second non-capturing group prevents version numbers
// the wild". The last non-capturing group prevents version numbers
// followed by a comma from matching.
let pseudosem_regex_str = r"(\d+(?:\.\d+)+(?:[-._:]?[A-Za-z0-9]+)*)(?!,)";
let pseudosem_regex_str = r"(\d+(?:\.\d+)+(?:[-._:]?[A-Za-z0-9]+)*)(?:[^,]|$)";
/* There are a few different version formats that can appear in strings
together, and in order to extract the correct one, they must be searched