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! {
|
||||
static ref FULL_RELATIVE_PATTERN: Regex = Regex::new(concat!(
|
||||
"(?<sign>[-+])?",
|
||||
r"(?:(?<year>\d+)\s?(?:y|yrs?|years?))?",
|
||||
r"(?:(?<month>\d+)\s?(?:mon|months?))?",
|
||||
r"(?:(?<week>\d+)\s?(?:w|wks?|weeks?))?",
|
||||
r"(?:(?<day>\d+)\s?(?:d|days?))?",
|
||||
r"(?:(?<hour>\d+)\s?(?:h|hrs?|hours?))?",
|
||||
r"(?:(?<minute>\d+)\s?(?:m|mins?|minutes?))?",
|
||||
r"(?:(?<second>\d+)\s?(?:s|secs?|seconds?))?"
|
||||
r"(?:(?<year>\d+)\s?(?:years?|yrs?|y)\s*)?",
|
||||
r"(?:(?<month>\d+)\s?(?:months?|mon)\s*)?",
|
||||
r"(?:(?<week>\d+)\s?(?:weeks?|wks?|w)\s*)?",
|
||||
r"(?:(?<day>\d+)\s?(?:days?|d)\s*)?",
|
||||
r"(?:(?<hour>\d+)\s?(?:hours?|hrs?|h)\s*)?",
|
||||
r"(?:(?<minute>\d+)\s?(?:minutes?|mins?|m)\s*)?",
|
||||
r"(?:(?<second>\d+)\s?(?:seconds?|secs?|s)\s*)?"
|
||||
))
|
||||
.unwrap();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user