Hi, I am trying to use a perl regular expression to validate a form field where I am allowing someone to edit a sql date-time stamp in the format of '2004-02-05 21:43:34'.
I have found a pattern that works (at http://www.regexplib.com/RETester.aspx?regexp_id=93) which is; 20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1]))(T|\s) (([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9]) However, when I try to use it in a php if statement like this; if (!ereg("20\d{2}(-|\/)((0[1-9])|(1[0-2]))(-|\/)((0[1-9])|([1-2][0-9])|(3[0-1] ))(T|\s)(([0-1][0-9])|(2[0-3])):([0-5][0-9]):([0-5][0-9])",$date_time)) { echo "<p>You must provide a date and time in the format YYYY-MM-DD HH:MM:SS</p>"; echo "<form><input type=\"button\" value=\"Go back\" onClick=\"history.back()\"></form>"; } It doesn't match and allow valid strings through. Any suggestions? TIA, Verdon Ps. Please cc me in any replies to list as I am in digest mode. -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php