Return true/false for a matched/not matched regex

前端 未结 5 1169
时光说笑
时光说笑 2020-12-25 10:02

I have this regex on Javascript

var myS = \"00 - ??:??:?? - a\";
var removedTL = myS.match(/^(\\d\\d) - (\\?\\?|10|0\\d):(\\?\\?|[0-5]\\d):(\\?\\?|[0-5]\\d)          


        
5条回答
  •  一生所求
    2020-12-25 10:50

    var myS = "00 - ??:??:?? - a";
    var patt = new RegExp("^(\d\d) - (\?\?|10|0\d):(\?\?|[0-5]\d):(\?\?|[0-5]\d) - (.*)");
    var removedTL = patt.test(myS);
    

    removedTL will hold a boolean value true if matched, false if not matched

提交回复
热议问题