查找字符串的一部分并在php中将其用作自己的值

时间:2011-02-25 15:37:40

标签: php regex

在下面的示例中,有人可以告诉我如何在没有之后删除该号码。并将其用作值?

No.311 11 / 12ozs

1 个答案:

答案 0 :(得分:4)

$string = 'No.311 11/12ozs';
preg_match('/No\.([0-9]+)/is', $string, $matches);
// result would be in $matches[1]