[PHP] preg_match and dates

2009-03-02 Thread Michael A. Peters
I have absolutely no control over the source file. The source file is an xml file (er, sort of, it doesn't follow any particular DTD) and has a tag called VERBATIM_DATE in each record - looks to be required in their output as every record so far has it, but w/o a DTD hard to know - time of

Re: [PHP] preg_match and dates

2009-03-02 Thread Per Jessen
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 -MM-DD (not sure how I'll deal with the season case yet ... but I'm serious, that kind of thing in

Re: [PHP] preg_match and dates

2009-03-02 Thread Per Jessen
Michael A. Peters wrote: 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); If I were you, I'd

Re: [PHP] preg_match and dates

2009-03-02 Thread Michael A. Peters
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 -MM-DD (not sure how I'll deal with the season case yet ... but I'm serious, that