Date Regular Expression

后端 未结 2 351
广开言路
广开言路 2021-01-17 06:38

I\'m using a date field checker but I want to change the regex from DD-MM-YYYY to DD/MM/YYYY but I can\'t seem to get it working..

Here\'s the snippet of code:

2条回答
  •  遥遥无期
    2021-01-17 07:04

    Or:

    /^[0-9]{2}\/[0-9]{2}\/[0-9]{4}$/
    

    Or the full long form, which might help you understand what's going on:

    /^[0-9][0-9]\/[0-9][0-9]\/[0-9][0-9][0-9][0-9]$/
    

    This assumes you want exactly two digits for DD and MM and exactly four for YYYY.

提交回复
热议问题