mirror of
https://github.com/loot/libloot.git
synced 2026-07-27 14:16:01 -07:00
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:
@@ -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
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user