【发布时间】:2023-04-11 04:21:01
【问题描述】:
</tr>
<tr class='htmllist_tr' style="background-color:yellow" ><td class='htmllist_td' >INDX01</td>
<td class='htmllist_td_nbr' >964.87</td>
<td class='htmllist_td_nbr' >95.13</td>
<td class='htmllist_td' >NehaA9.86</td>
</tr>
<tr class='htmllist_tr' ><td class='htmllist_td' >UNDOTBS1</td>
<td class='htmllist_td_nbr' >156.25</td>
<td class='htmllist_td_nbr' >8</td>
<td class='htmllist_td' >NehaA5.12</td>
</tr>
想在<tr>和</tr>标签之间找到NehaA然后改变
`<tr class='htmllist_tr'>`
或
<tr class='htmllist_tr' style="background-color:yellow">
到
`<tr class='htmllist_tr' style="background-color:red">` *
试过了
sed -e "/NehaA/ s/\'<tr class='htmllist_tr'>\'/\'<tr class='htmllist_tr' style="background-color:red">\'/ ;" 2932_TABLE2.txt
没有用,请帮忙
【问题讨论】:
-
在 awk/sed 中做这件事不是最好的主意。为什么不使用 Python+Beautiful Soup?在 perl 中你可以使用(我想,我以前没用过)HTML::Parser.
-
HTML 和 XML 一样,是结构化数据。你不能把它当作一个普通的文本文件。 many modules available 会解析你的 HTML 并允许你修改它。