开发者

REGEX for date format Jun 12 2011 12:00:00:000AM

开发者 https://www.devze.com 2023-03-14 08:10 出处:网络
Just a quick one, what\'s the best REGEX to pick out dates of this format: Jun 12 2011 12:00:00:000AM Mon开发者_如何转开发ths are always 3 letters and days are also 2 digits./\\w{3} \\d{2} \\d{4} \\

Just a quick one, what's the best REGEX to pick out dates of this format:

Jun 12 2011 12:00:00:000AM

Mon开发者_如何转开发ths are always 3 letters and days are also 2 digits.


/\w{3} \d{2} \d{4} \d{2}:\d{2}:\d{2}:\d{3}(AM|PM)/i

To capture part of it just add some parthensis whenever you need

If you need to validate a string of course don't use REGEX but http://php.net/manual/en/function.checkdate.php


try this (untested)

/(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ([0-3]\d) ([12][09]\d{2}) ([01]\d):([0-5]\d):([0-5]\d):(\d{3})(AM|PM)/
0

精彩评论

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