Posted By

dreadwarrior on 07/22/09


regex regexp regular Expression

Versions (?)

Who likes this?

1 person have marked this snippet as a favorite


Regular Expression, getting all parts of a E-Mail Date Header field

 / Published in: Regular Expression

This snippet is useful if you want to extract the relevant parts out of an Date header field of an email message. It was created according to the RFC 5322 rules. It supports named capturing groups for easier access of the date parts.

tested in PHP 5.2.6


  • deal with obs-% data
  1. '~(\s?(?P<weekday>Mon|Tue|Wed|Thu|Fri|Sat|Sun))[,]?\s?(?P<day>[0-9]{1,2})\s(?P<month>Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(?P<year>[0-9]{4})\s(?P<hours>[0-9]{2}):(?P<minutes>[0-9]{2})(:(?P<seconds>[0-9]{2}))?\s(?P<timezone>[\+|\-][0-9]{4})\s?~'

Report this snippet  

You need to login to post a comment.