Per Jessen wrote:
Michael A. Peters wrote:
What I'm trying to do is write a preg matches for each case I come
across - if it matches the preg, it then parses according to the
pattern to get me an acceptable YYYY-MM-DD (not sure how I'll deal
with the season case yet ... but I'm serious, that kind of thing in
there several times)
To at least get started though, is there a wildcard defined that says
match a month?
IE
/^([0-9]{2})[\s-](MONTH_MATCH)[\s-]([0-9]{4,4}$/
where MONTH is some special magic that matches Mar March Apr April
etc. ?
Just write one yourself.
This is what I have so far -
$pattern[] = "/^([0-9]{1,2})[\s-]([A-Z][a-z]*)[\s-]([0-9]{4,4})$/i";
$clean[] = "\\3-\\2-\\1";
$pattern[] = "/^([A-Z][a-z]*)[\s-]([0-9]{4,4})$/";
$clean[] = "\\2-\\1-01";
$foo = preg_replace($pattern, $clean, $verb_date);
That was enough for me to discover some collectors have two digit years
and I can't differentiate 1902 from 2002 so I'll have to flag those and
bug the curator to fix 'em.
I'd rather have ([A-Z][a-z]*) be replaced with something that makes sure
it is a valid short or long month, writing one myself is not impossible
but if there is a date wildcard (or a tried and proven pattern) that can
match month built into php then it is better to use it, no?
--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php