Skip to content

Commit 71cc5eb

Browse files
authored
Fix regex pattern for extracting relative dates to prevent matching at the start of a string (#192)
1 parent 191789f commit 71cc5eb

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

‎packages/TGUIKit/Sources/Extensions.swift‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3480,7 +3480,7 @@ private func extractRelativeDates(from text: String, referenceDate: Date) -> [Ex
34803480

34813481
// Pattern B examples:
34823482
// "20m", "2h", "3d", "1w", "20 min", "10мин", "5хв", "2soat"
3483-
let patternB = #"\b(\d+(?:[.,]\d+)?)\s*([[:alpha:]\p{M}]{1,12}\.?)\b"#
3483+
let patternB = #"(?<!\S)(\d+(?:[.,]\d+)?)\s*([[:alpha:]\p{M}]{1,12}\.?)\b"#
34843484

34853485
// Pattern C examples (implied "1"):
34863486
// "через минуту", "через час", "in a minute", "in an hour", "nach einer Stunde"

0 commit comments

Comments
 (0)