qualsiasi Posted July 28, 2009 Share Posted July 28, 2009 Hello, I tried to check preg_match syntax for be able to convert my pattern from ereg to preg_match function, but i have some problem understanding preg_match pattern building. Can someone help me? The pattern i need to convert is this: ereg("([0-9]{4}).([0-9]{1,2}).([0-9]{1,2})", $data[$nn], $regs) its a simple date check loop, i would like to: preg_match("...........................", $data[$nn], $regs) Thanks in advance. Quote Link to comment Share on other sites More sharing options...
aschk Posted July 28, 2009 Share Posted July 28, 2009 /facepalm Did you even try? <?php preg_match("/([0-9]{4}).([0-9]{1,2}).([0-9]{1,2})/", $data[$nn], $regs) ?> Quote Link to comment Share on other sites More sharing options...
rhodesa Posted July 28, 2009 Share Posted July 28, 2009 I think you are looking for: preg_match('/([0-9]{4})\.([0-9]{1,2})\.([0-9]{1,2})/', $data[$nn], $matches); but it can be shortened to: preg_match('/(\d{4})\.(\d{1,2})\.(\d{1,2})/', $data[$nn], $matches); Quote Link to comment Share on other sites More sharing options...
qualsiasi Posted July 29, 2009 Author Share Posted July 29, 2009 Thanks a lot rhodesa, solved. @aschk: as far i had to edit a important script not wrote by me, that write sensible data on DB, where there is many of this call, i wonted to risk to do mistake by simple add basic slash, because after i saw some perl pattern example, i found it more complex and then i was not sure it was really right. 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.