mirror of
https://github.com/Xevion/time-banner.git
synced 2025-12-06 01:16:36 -06:00
fix: regex greedy pattern stops early when parsing shorter unit markers
This commit is contained in:
@@ -17,13 +17,13 @@ impl Months for Duration {
|
|||||||
lazy_static! {
|
lazy_static! {
|
||||||
static ref FULL_RELATIVE_PATTERN: Regex = Regex::new(concat!(
|
static ref FULL_RELATIVE_PATTERN: Regex = Regex::new(concat!(
|
||||||
"(?<sign>[-+])?",
|
"(?<sign>[-+])?",
|
||||||
r"(?:(?<year>\d+)\s?(?:y|yrs?|years?))?",
|
r"(?:(?<year>\d+)\s?(?:years?|yrs?|y)\s*)?",
|
||||||
r"(?:(?<month>\d+)\s?(?:mon|months?))?",
|
r"(?:(?<month>\d+)\s?(?:months?|mon)\s*)?",
|
||||||
r"(?:(?<week>\d+)\s?(?:w|wks?|weeks?))?",
|
r"(?:(?<week>\d+)\s?(?:weeks?|wks?|w)\s*)?",
|
||||||
r"(?:(?<day>\d+)\s?(?:d|days?))?",
|
r"(?:(?<day>\d+)\s?(?:days?|d)\s*)?",
|
||||||
r"(?:(?<hour>\d+)\s?(?:h|hrs?|hours?))?",
|
r"(?:(?<hour>\d+)\s?(?:hours?|hrs?|h)\s*)?",
|
||||||
r"(?:(?<minute>\d+)\s?(?:m|mins?|minutes?))?",
|
r"(?:(?<minute>\d+)\s?(?:minutes?|mins?|m)\s*)?",
|
||||||
r"(?:(?<second>\d+)\s?(?:s|secs?|seconds?))?"
|
r"(?:(?<second>\d+)\s?(?:seconds?|secs?|s)\s*)?"
|
||||||
))
|
))
|
||||||
.unwrap();
|
.unwrap();
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user