I have a website where I need to parse date/time strings from receipts. These can be in a variety of different formats -- for instance, one string could be '11/04/2009 12:46PM', while another could be 'Mar06'09 10:57AM'. I need to get a standard date/time string out of them to do a database insert.
I'd like to avoid writing new php code for each client to parse their string. Something I do elsewhere is store a regular expression in a database field -- that way, in order to validate data, I can just do
<?php
if ( ! preg_match($row['regex'], $variable_user_input) ) { ... }
?>
So if I need to add a client that has a different validation criteria, I just have to write a new regex, which goes in the client database record, instead of writing, testing, and deploying new php code on the website. It's a more robust system.
Is there something like a regular expression, when I can input a string, input another transformation string, and get my date-time as output?