Help with regular expression for reg ex validator
-
Let me begin by saying I am not fluent in regex. I need a regex that will validate a date AND time value, not just date and not just time...both. I found a regex written by Bernat Sales at regexlib.com that will validate a date AND time entry, however, it only validates it in European formate (dd/mm/yyyy hh:mm:ss). I need it to validate only in American format (mm/dd/yyyy hh:ss:mm). Can someone, out of the goodness of their heart, please modify this regex to accomplish my goal of validating in American format. Here is Bernat's creation from which you can start: ^((((([0-1]?\d)|(2[0-8]))\/((0?\d)|(1[0-2])))|(29\/((0?[1,3-9])|(1[0-2])))|(30\/((0?[1,3-9])|(1[0-2])))|(31\/((0?[13578])|(1[0-2]))))\/((19\d{2})|([2-9]\d{3}))|(29\/0?2\/(((([2468][048])|([3579][26]))00)|(((19)|([2-9]\d))(([2468]0)|([02468][48])|([13579][26]))))))\s(([01]?\d)|(2[0-3]))(:[0-5]?\d){2}$ Again, I am not a regex guru, nor do I plan to be. I just need this regex for a current page I'm writing. Thanks in advance.
-
Let me begin by saying I am not fluent in regex. I need a regex that will validate a date AND time value, not just date and not just time...both. I found a regex written by Bernat Sales at regexlib.com that will validate a date AND time entry, however, it only validates it in European formate (dd/mm/yyyy hh:mm:ss). I need it to validate only in American format (mm/dd/yyyy hh:ss:mm). Can someone, out of the goodness of their heart, please modify this regex to accomplish my goal of validating in American format. Here is Bernat's creation from which you can start: ^((((([0-1]?\d)|(2[0-8]))\/((0?\d)|(1[0-2])))|(29\/((0?[1,3-9])|(1[0-2])))|(30\/((0?[1,3-9])|(1[0-2])))|(31\/((0?[13578])|(1[0-2]))))\/((19\d{2})|([2-9]\d{3}))|(29\/0?2\/(((([2468][048])|([3579][26]))00)|(((19)|([2-9]\d))(([2468]0)|([02468][48])|([13579][26]))))))\s(([01]?\d)|(2[0-3]))(:[0-5]?\d){2}$ Again, I am not a regex guru, nor do I plan to be. I just need this regex for a current page I'm writing. Thanks in advance.
You may look at this tool http://www.ultrapico.com/Expresso.htm[^] or search here http://www.regexlib.com/(A(ETSM97iRt59npddwlQbtzFNef5emeob0TT2o8x42-2FZE4R5sd9jQ_I7XKHMO3HGLxVg4cIJnDRXTjAozW-fMhAp1a-s43iaZi06M4wawpE1))/DisplayPatterns.aspx[^]
I know the language. I've read a book. - _Madmatt
-
You may look at this tool http://www.ultrapico.com/Expresso.htm[^] or search here http://www.regexlib.com/(A(ETSM97iRt59npddwlQbtzFNef5emeob0TT2o8x42-2FZE4R5sd9jQ_I7XKHMO3HGLxVg4cIJnDRXTjAozW-fMhAp1a-s43iaZi06M4wawpE1))/DisplayPatterns.aspx[^]
I know the language. I've read a book. - _Madmatt
Thanks for the search suggestion, but that is to the site where I found Bernat's regex by searching already. His is the closest I found to what I need (it only needs to swap the month and date tests). When I have time (won't for a month), I'll check out the tool to which you sent me a link.
-
Let me begin by saying I am not fluent in regex. I need a regex that will validate a date AND time value, not just date and not just time...both. I found a regex written by Bernat Sales at regexlib.com that will validate a date AND time entry, however, it only validates it in European formate (dd/mm/yyyy hh:mm:ss). I need it to validate only in American format (mm/dd/yyyy hh:ss:mm). Can someone, out of the goodness of their heart, please modify this regex to accomplish my goal of validating in American format. Here is Bernat's creation from which you can start: ^((((([0-1]?\d)|(2[0-8]))\/((0?\d)|(1[0-2])))|(29\/((0?[1,3-9])|(1[0-2])))|(30\/((0?[1,3-9])|(1[0-2])))|(31\/((0?[13578])|(1[0-2]))))\/((19\d{2})|([2-9]\d{3}))|(29\/0?2\/(((([2468][048])|([3579][26]))00)|(((19)|([2-9]\d))(([2468]0)|([02468][48])|([13579][26]))))))\s(([01]?\d)|(2[0-3]))(:[0-5]?\d){2}$ Again, I am not a regex guru, nor do I plan to be. I just need this regex for a current page I'm writing. Thanks in advance.
Here you can use it Will detect American Date and time with whitespace RegExp: /[\d]{2}\s[\d]{2}\s[\d]{4} [\d]{2}:[\d]{2}:[\d]{2}/g
-
Here you can use it Will detect American Date and time with whitespace RegExp: /[\d]{2}\s[\d]{2}\s[\d]{4} [\d]{2}:[\d]{2}:[\d]{2}/g
Thanks, but that won't validate February or 30 versus 31 days properly.