sonar 1 left. all regex fixed

This commit is contained in:
Cindy Chang
2024-08-13 13:52:05 +08:00
parent db8f8eefd6
commit 2c0d5fe8ee
3 changed files with 27 additions and 3 deletions

View File

@@ -228,7 +228,8 @@ export function formatTime(seconds) {
export function formatMaxTwo(times) {
const formattedTimes = [];
for (let time of times) {
let units = time.match(/\d+[dhms]/g); // 匹配數字和單位(天、小時、分鐘、秒)
// 匹配數字和單位(天、小時、分鐘、秒), 假設數字不可能大於10位數
let units = time.match(/\d{1,10}[dhms]/g);
let formattedTime = '';
let count = 0;