i have text one: the cat born on 1980 , lives ...
so want cat's age regex (the text have more 1 occurrence of number 4 digits).
i'm trying preg_match('/born on [0-9]{4}/', $text, $matches)
result is: array('born on 1980')
. want ignore before year.
group value want first item of array.
$text = 'the cat born on 1980 , lives ...'; preg_match('/born on ([0-9]{4})/', $text, $matches); echo $matches[1];
output:
1980