Possible Duplicate:
Extract numbers from a string
I am using preg_match()
to extract a number from a string.
Example string is: advent_id ----------- 3163 (1 row)
, I need to extract the number followed by the hyphens and not the number of rows. What is the correct way of writing a regex for it?
I tried preg_match('/^advent_id\s------------\s(.*)\s\(/', $cn, $matches);
where $cn
has that source string, but it did not work. Note that the number could have any number of digits.