如何从preg_match()获取文本?

Ary*_*n G 0 php regex preg-match

$text = "About 5,590 results";

preg_match("/of about <b>(.*?)</", $text, $matches);
Run Code Online (Sandbox Code Playgroud)

它返回5590,但当我尝试:

$text = "4 results";
preg_match("/of about <b>(.*?)</", $text, $matches);
Run Code Online (Sandbox Code Playgroud)

这种情况有什么模式吗?我想从"4结果"中得到"4"

Aur*_*osa 5

如果您只需要数字,可以使用此正则表达式:

$regex = "/\d+[\.,]?\d*/";
Run Code Online (Sandbox Code Playgroud)

这将匹配以下格式的数字:

  • 5.590
  • 5,590
  • 5590