只获取标签之间的数字


get only numbers between tags

我想要在html内容中获得非十六进制或unicode的标记之间的数字像这样使用正则表达式

<a href="/sam2/example-3.php">go to page 13</a> 0x91 0x26 exchange hello98.25 &#8230;

返回

13和98.25

我看不出你试图做的有任何用处……如果你想创建分页,你应该使用GET或POST数据,例如:

 <a href="/sam2/example-3.php?page=13">go to page 13</a>

然后您可以检索页面值并在脚本中使用它

 $page = $_GET['page'];

但无论如何,回答您的问题:

$content = '<a href="/sam2/example-3.php">go to page 13</a> 0x91 0x26 exchange hello98.25 &#8230;';
$page_id = preg_replace('/('"(.*)'"|0x.[0-9]+|'&'#.[0-9]+|[^0-9'.])/', ' ', $content);
echo $page_id;
//Result: 13 98.25 (string with each number separated by space)

祝你好运。

我终于为它编写了正则表达式

'/(?:&#'d{2,4};)|(?:0[xX][0-9a-fA-F]+)|('d+['.'d]*)|<'s*[^>]+>/i'

它的工作性能