Regex帮助,应该很简单


Regex help, should be really simple

$newHTML = str_replace("<tr><td>1-30 of 699 results.1 | 2 | 3 | 4 | 5 | 6 | 7 | 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>", "", $newHTML);
            $newHTML = str_replace("<tr><td>31-60 of 699 results.First &Acirc;&middot; Prev &Acirc;&middot; 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>", "", $newHTML);
            $newHTML = str_replace("<tr><td>61-90 of 699 results.First &Acirc;&middot; Prev &Acirc;&middot; 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>","",$newHTML);
            $newHTML = str_replace("<tr><td>91-120 of 699 results.First &Acirc;&middot; Prev &Acirc;&middot; 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>","",$newHTML);
            $newHTML = str_replace("<tr><td>121-150 of 699 results.First &Acirc;&middot; Prev &Acirc;&middot; 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>","",$newHTML);

上面的代码是我没有使用regex,因为我根本不理解regex。

**<tr><td>**121-150 **of 699 results.First &Acirc;&middot; Prev &Acirc;&middot; 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>**

以上文为例,121-150是$newHTML中唯一不为常数的数字。字符串的其余部分出现多次。我如何通配符这些点?ie .

<tr><td>###-### of 699 results.First &Acirc;&middot; Prev &Acirc;&middot; 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>

其中的数字符号是可能需要删除的数字

将字符串集转换为PHP正则表达式非常简单。注意事项如下:

'd+表示1个或多个数字,因此您将使用它来代替每个数字。

'|代表一条竖线,所以你将用它来代替每条竖线。

因此,匹配给定字符串集的正则表达式是:
<tr><td>'d+-'d+ of 'd+ results.First &Acirc;&middot; Prev &Acirc;&middot; 1 '| 2 '| 3 '| 4 '| 5 '| 6 '| 7 '| 8-15 &Acirc;&middot; Next &Acirc;&middot; Last</td></tr>