neuroxik Posted March 18, 2011 Share Posted March 18, 2011 Alright everyone, So I'm stuck on the one, especially because I've never really took the time to learn regex's correctly, but here's my problem if anyone's willing to help. 2011-03-04T18:40:12-05:00 The above line is the kind of line I want to find with preg_match(), this is what I tried (among many variations of it for the past 45 minutes) $tests['xmls_ts'] = "2011-03-04T18:40:12-05:00"; //$xmls_pattern = "/([0-9]{4})-([0-9]{2})-([0-9]{2})T([0-9]{2})[0-9]{2})\[0-9]{2})\[0-9]{2})-([0-9]{2})\[0-9]{2})/"; $xmls_pattern = "/(d{4})-(d{2})-(d{2})T(d{2}{2}{2}-d{2}{2})/"; $fd = preg_match($xmls_pattern,$tests['xmls_ts'],$matches); if($fd) { echo 'yes'; } else { echo 'no'; } Can anyone tell me where I'm going wrong? Quote Link to comment Share on other sites More sharing options...
PFMaBiSmAd Posted March 18, 2011 Share Posted March 18, 2011 The d's need to be escaped so that they mean decimal digits rather than the letter d - $xmls_pattern = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}:\d{2}:\d{2}-\d{2}:\d{2})/"; Quote Link to comment Share on other sites More sharing options...
neuroxik Posted March 18, 2011 Author Share Posted March 18, 2011 Wow, it's works... thanks so much! The d's need to be escaped so that they mean decimal digits rather than the letter d - $xmls_pattern = "/(\d{4})-(\d{2})-(\d{2})T(\d{2}:\d{2}:\d{2}-\d{2}:\d{2})/"; Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.