开发者

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

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

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜