reqular exp从字符串中获取最后一个数字

ahm*_*mad 4 php regex

大家好
我如何从字符串中获取数字(正数),如果字符串语法如下:

t_def_type_id_2
t_def_type_id_22
t_def_type_id_334

所以,在第一个字符串中我想得到1,在第二个字符串中我想得到22而在第三个字符串中我想得到334使用preg_match_all或任何其他可靠的php函数

cod*_*ict 5

你可以使用正则表达式

\d+$
Run Code Online (Sandbox Code Playgroud)

preg_match