Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Regex unexpected token [closed]

When I add this regex into validation engine I get a javascript error: "unexpected token", it seems that the regex is wrong because it is underline with red, why?

"time1":{    
   "regex": ^([0-9]|0[0-9]|1[0-3]|2[0-3]):[0-5][0-9]$,
   "alertText": "* Invalid Time"
}
like image 464
kosnkov Avatar asked Mar 18 '13 19:03

kosnkov


1 Answers

Replace

   "regex": ^([0-9]|0[0-9]|1[0-3]|2[0-3]):[0-5][0-9]$,

with

   "regex": /^([0-9]|0[0-9]|1[0-3]|2[0-3]):[0-5][0-9]$/,

See the syntax of regex literals.

like image 59
Denys Séguret Avatar answered Nov 15 '22 12:11

Denys Séguret