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. Link to comment https://forums.phpfreaks.com/topic/167804-convert-ereg-to-preg_match/ 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) ?> Link to comment https://forums.phpfreaks.com/topic/167804-convert-ereg-to-preg_match/#findComment-884980 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); Link to comment https://forums.phpfreaks.com/topic/167804-convert-ereg-to-preg_match/#findComment-884985 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. Link to comment https://forums.phpfreaks.com/topic/167804-convert-ereg-to-preg_match/#findComment-885688 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.