From 071e9b6c2c359ad86d5e9fea47696ebe3ef153b1 Mon Sep 17 00:00:00 2001 From: natsoni Date: Sun, 13 Oct 2024 12:54:58 +0900 Subject: [PATCH] Include optional seconds in search bar date --- frontend/src/app/shared/regex.utils.ts | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/frontend/src/app/shared/regex.utils.ts b/frontend/src/app/shared/regex.utils.ts index a349e9633..b3d277c9f 100644 --- a/frontend/src/app/shared/regex.utils.ts +++ b/frontend/src/app/shared/regex.utils.ts @@ -313,20 +313,24 @@ export function getRegex(type: RegexType, network?: Network): RegExp { } regex += `)`; // End the non-capturing group break; - // Match a date in the format YYYY-MM-DD (optional: HH:MM) + // Match a date in the format YYYY-MM-DD (optional: HH:MM or HH:MM:SS) // [Testing Order]: any order is fine case `date`: regex += `(?:`; // Start a non-capturing group regex += `${NUMBER_CHARS}{4}`; // Exactly 4 digits regex += `[-/]`; // 1 instance of the symbol "-" or "/" - regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits + regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits regex += `[-/]`; // 1 instance of the symbol "-" or "/" - regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits + regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits regex += `(?:`; // Start a non-capturing group regex += ` `; // 1 instance of the symbol " " - regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits + regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits regex += `:`; // 1 instance of the symbol ":" - regex += `${NUMBER_CHARS}{1,2}`; // Exactly 4 digits + regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits + regex += `(?:`; // Start a non-capturing group for optional seconds + regex += `:`; // 1 instance of the symbol ":" + regex += `${NUMBER_CHARS}{1,2}`; // 1 or 2 digits + regex += `)?`; // End the non-capturing group regex += `)?`; // End the non-capturing group. This group appears 0 or 1 times regex += `)`; // End the non-capturing group break;