$str= 'content123';
preg_match("/content\d+/", $str, $matches);
print_r($matches);
preg_match("/content\d+/", $str, $matches);
print_r($matches);
输出Array ( [0] => content123 )
想要使使用正则时作为匹配的值 不输出 即不输出content 可以使用以下
$str= 'content123';
preg_match("/content(\d+)/", $str, $matches);
print_r($matches);
即将需要输出的部分用()包裹 得到的结果为以下
输出Array ( [0] => content123 [1] => 123 )