开发者

Date input Regex

开发者 https://www.devze.com 2023-02-25 18:04 出处:网络
I have this very nice regex that I got from the net which makes my date inputs dd/MM/yyyy, but now I would like to get it to only be ddMMyyyy, but I can\'t seem to get the / removed. Any help would be

I have this very nice regex that I got from the net which makes my date inputs dd/MM/yyyy, but now I would like to get it to only be ddMMyyyy, but I can't seem to get the / removed. Any help would be greatly apreciated.

(((((0[1-9])|(1\d)|(2[0-8]))\/((0[1-9])|(1[0-2])))|((31\/((0[13578])|(1[02])))|((29|30)\/((0[1,3-9])|(1[0-2])))))\/((20[0-9][0-9])|(19[0-9][0-9])))|((29\/02\/(19|20)(([开发者_JAVA技巧02468][048])|([13579][26]))))


Try this:

(((((0[1-9])|(1\d)|(2[0-8]))((0[1-9])|(1[0-2])))|((31((0[13578])|(1[02])))|((29|30)((0[1,3-9])|(1[0-2])))))((20[0-9][0-9])|(19[0-9][0-9])))|((2902(19|20)(([02468][048])|([13579][26]))))


Is DateTime.TryParse method not appropriate?


When removing instances of /, make sure you also remove the accompanying \ which is used for escaping.


You have to remove all the \/.

0

精彩评论

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