I think it's often helpful to start with zero generality. Figure out the tricky bits of the match operation and regular expression pattern first, then generalize the pattern.
Let's assume you want to match one or more of these specific timestamps in a string:
Mar 11 08:02:08
Mar 11 08:02:08.32
Mar 11 2011 08:02:08
Mar 11 2011 08:02:08.32
This expression will match and capture them:
m/(Mar 11 (?:2011 )?08:02:08(?:\.32)?)/g;
Simple.
Now it's easy to generalize this pattern as much as you need to for your specific application. The following generalization is probably sufficient:
m{((?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s+ \d\d?\s+(?:(?:19|20)\d\d\s+)?\d\d:\d\d:\d\d(?:\.\d\d)?)}gx;
Jim
In reply to Re^3: regex for multiple dates
by Jim
in thread regex for multiple dates
by Anonymous Monk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |