-----Original Message----- From: Paul Halliday [mailto:paul.halliday@xxxxxxxxx] Sent: Thursday, October 27, 2011 2:43 PM To: PHP-General Subject: What is wrong with this preg_match? I have the following: if (isset($argc)) { if ($argc == 1 || $argc > 2 || !preg_match("(\d{4}-\d{2}-\d{2})", $argv[1])) { echo "\nUsage: $argv[0] <yyyy-mm-dd>\n\n"; exit; } else { $base_date = $argv[1]; } } else { $base_date = date('Y-m-d'); } When I run it: $ ./process_patches.php 201-01-01 Usage: ./process_patches.php <yyyy-mm-dd> patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-011-01 Usage: ./process_patches.php <yyyy-mm-dd> patches@innm2 ~/Code/Oculi $ ./process_patches.php 2011-01-011 Works.. What am I doing wrong? Thanks! -- Paul Halliday http://www.squertproject.org/ Paul, To me, it looks like you're just getting the next 2 digits, so 2011-01-011 is getting 2011-01-01 and truncating the last 1. If you had used (I think) "^(\d{4}-\d{2}-\d{2})$" I think that would give you what you want... (but my reg-ex is horrible) Steve -- PHP General Mailing List (http://www.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php