如何从页面中抓取一个词

How to grab a word from a page

我想知道如何使用 PHP 从外部页面抓取一些文本。 我认为 preg_match() 可以提供帮助,但我不知道如何使用它。

页面正文如下:

dragontail-5.7.2.tgz

我只需要抢

5.7.2

感谢您的帮助。

看看这个: https://regex101.com/r/cF8mS1/1

/([0-9.]+)/gm

表示 "Select all the integer characters since they are more than 1, and include the "。”还有,并在多行上也给我所有这些。谢谢。” 最后要做的是删除最后一个或第一个字符“.”,所以:

if (preg_match('/([0-9.]+)/gm', $input, $matches)) {
    $result = trim($matches[1], '.');
} else {
    $result = null;
}