regex - How can I extract all 4-digit numbers from a php text? -
for example : had text testt1591fff44f43f0015ffef159
given there won't more 4 consecutive number in string, how can extract 1591 , 0015 out of php?
http://www.php.net/manual/en/function.preg-match-all.php
<?php $text = 'testt1591fff44f43f0015ffef159'; preg_match_all('~\d{4}~', $text, $matches); ?>
didnot test code
Comments
Post a Comment