Return true/false for a matched/not matched regex

前端 未结 5 1264
时光说笑
时光说笑 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:41

    The more appropriate function here might be RegExp.test, which explicitly gives you true or false.

    console.log(/lolcakes/.test("some string"));
    // Output: false
    
    console.log(/lolcakes/.test("some lolcakes"));
    // Output: true
    

提交回复
热议问题