Hi, I am trying to extract 1
and 125
from this text with PHP:
preg_match("/^(?P<digit>\d+)/", "1 Foo ($125)",$m)
Can you please help?
Thanks
Hi, I am trying to extract 1
and 125
from this text with PHP:
preg_match("/^(?P<digit>\d+)/", "1 Foo ($125)",$m)
Can you please help?
Thanks
Try this:
<?php
preg_match_all('/\d+/', '1 Foo ($125) bar', $matches);
var_dump($matches);
?>
Note that I used preg_match_all which literally returns all matches in the pattern.