gpt4 book ai didi

php - 使用 preg_match 时忽略空格

转载 作者:行者123 更新时间:2023-12-02 17:48:12 24 4
gpt4 key购买 nike

我正在使用 preg_match try catch 此 html 结构中的“数据”,但目前它没有返回任何内容,我认为这可能是因为空白?

只是想知道 preg_match 有什么问题?

html

  <td><strong>Title</strong></td>

<td>Data</td>

php

preg_match("~<td><strong>Title</strong></td>

<td>([a-zA-Z0-9 -_]+)</td>~", $html, $match);

最佳答案

与其尝试重现空白的确切顺序(由于行尾,这可能很难甚至不可能),只需使用 \s* 来指示“任意数量(包括零)的空白字符”- 这包括空格、制表符、换行符、回车符……正是您在这里需要的。

关于php - 使用 preg_match 时忽略空格,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/11817494/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com