开发者

How can I recognize these "default-more-or-less" type of strings?

开发者 https://www.devze.com 2023-03-26 07:45 出处:网络
I have some strings like these : 00. 00:00:00 - 00. - 00:00:00 - 00. 00:00:00 00 - 00:00:00 00) 00:00:00

I have some strings like these :

00. 00:00:00 - 
00. - 00:00:00 - 
00. 00:00:00 
00 - 00:00:00
00) 00:00:00

so, how can you see, they are similar (not equal). I need to "extrapolate" the internal block (formed by 00:00:00) and remove the rest of characters.

Every 0 in the example must开发者_运维知识库 be integer from 0 to 9 or the char ?.

How can I do it on jQuery? Regex?

As starting point to check this I've made a Fiddle


var result = strings.match(/[\d?]{2}:[\d?]{2}:[\d?]{2}/g);

result will be an array with all the matches of NN:NN:NN, ??:??:??, or any combined version of N and ?.

Here is a demo for a string with a single match & a string with multiple matches.

0

精彩评论

暂无评论...
验证码 换一张
取 消