asehgal asehgal - 3 months ago 7x
PHP Question

preg match extract digits from string after pattern

I have a string of the form


How can I extract just the
portion in PHP ? I need to detect the string_t first and then pull out the digits.


You want something like this:

preg_match('/string_t_(\d+)/', $string, $captures);

$captures[1] will contain <digits> (assuming <digits> is composed entirely of numbers - if it's not, use the more general (.+) in place of (\d+)).