修正正则表达式以匹配含小时的时间

This commit is contained in:
KoolShow
2024-02-12 17:20:18 +08:00
committed by GitHub
parent 3da70d7e27
commit b817a0c807

View File

@ -591,7 +591,7 @@ InlineSpan buildContent(
if (patternStr.isNotEmpty) {
patternStr += "|";
}
patternStr += r'(\b\d{1,2}[:]\d{2}\b)';
patternStr += r'(\b(?:\d+[:])?[0-5]?[0-9][:][0-5]?[0-9]\b)';
final RegExp pattern = RegExp(patternStr);
List<String> matchedStrs = [];
void addPlainTextSpan(str) {
@ -639,7 +639,7 @@ InlineSpan buildContent(
},
),
);
} else if (RegExp(r'^\b[0-9]{1,2}[:][0-9]{2}\b$').hasMatch(matchStr)) {
} else if (RegExp(r'^\b(?:\d+[:])?[0-5]?[0-9][:][0-5]?[0-9]\b$').hasMatch(matchStr)) {
spanChilds.add(
TextSpan(
text: ' $matchStr ',