客户有大约 7,000 种产品,其描述中包含“您的价格:$...”,价格已输入(没有现有的通配符)。
以下是描述示例:
< /table>部分# : | FIV000-2100 |
零售价: | 26.39 美元 |
您的价格: | $23.75 |
|
是否有正则表达式可用于删除“您的价格”行?如果我们还想删除零售价格行怎么办?
A client has ~7,000 products with a "Your Price: $..." in the description, the price is typed in (there is no existing wildcard).
Here is an example of a description:
<table cellpadding="5" border="0" width="100%"><tbody><tr><td><strong>Part #: </strong></td><td>FIV000-2100</td></tr><tr><td><strong>Retail Price: </strong></td><td>$26.39</td></tr><tr><td class="price"><strong>Your Price: </strong></td><td class="price">$23.75</td></tr><tr><td align="center" colspan="2"/></tr></tbody></table>
Is there a regular expression to use to just remove the Your Price row? What if we wanted to remove the Retail Price row as well?
发布评论
评论(2)
您可以执行以下操作(假设
$str
是 html 字符串):空字符串将替换为空字符串,从而将其删除。
编辑:
转义一些东西以使其工作。我还强烈建议您使用 HTML 解析器。我们称其为快速而肮脏的方法。
You can do something like this (provided
$str
is the html string):The empty string will replace it with nothing, thus removing it.
EDIT:
Escaped some stuff to make it work. I also urge you to use a HTML parser. Let's call this the quick and dirty method.
我强烈建议您为此使用 HTML 解析器。话虽这么说,以下内容很可能会满足您的要求:
我不知道 MySQL 正则表达式语法,因此您可能需要仔细检查。
I strongly recommend you use an HTML parser for this. That being said, the following will most likely do what you want:
I don't know MySQL regex syntax, so you might want to double-check that.