【发布时间】:2012-02-25 01:29:14
【问题描述】:
您好,我有以下文件
<strong>Ramandand Sagar Krishna part 34</strong> Vasudev comes back
and girl disappears from Kansa's hand and the first temple she instructs Devs to make at Vindhyachal <a href="http://www.dailymotion.com/embed/video/x3p3gu?
width=320&theme=none&wmode=transparent">http://www.dailymotion.com/embed/video/x3p3gu?width=320&theme=none&wmode=transparent</a> <a
href="http://www.dailymotion.com/video/x3p3gu_krishna-part-34_shortfilms"
target="_blank">Krishna Part 34</a> <strong>Ramandand Sagar Krishna part 35</strong> Celebrations at Yashoda's house and Vasudev Devki freed from jail <a href="http://www.dailymotion.com/embed/video/x3p3sg?width=320&theme=none&wmode=transparent">
http://www.dailymotion.com/embed/video/x3p3sg?width=320&theme=none&wmode=transparent</a> <a href="http://www.dailymotion.com/video/x3p3sg_krishna-part-35_shortfilms" target="_blank">Krishna Part 35</a> <a href="http://www.dailymotion.com/video/x66a71_krishna-143_shortfilms" target="_blank">Krishna 143</a></em></div>
在上面的文件中我想替换
任何以下类型的 HTML
<a href="http://www.dailymotion.com/embed/video/x5ftx3?width=320">http://www.dailymotion.com/embed/video/x5ftx3?width=320</a>
关键字是任何具有wmode=transparent 或width=320 的HTML 标记应替换为空格。有没有简单的方法可以做到这一点?有很多HTML 标记,例如
<a href=""> </a> 在他们的行中没有 wmode=transparent。
上面发布的文件非常大,HTML 中有大约 30K 行,所以我只发布了相关行。
我在 Ubuntu 系统上。
【问题讨论】:
-
没有简单的方法可以使用 sed 可靠地做到这一点,因为使用正则表达式的 parsing HTML 不是一个好主意。
-
如果您将鼠标悬停在您分配给问题的标签上,您会注意到,在最坏的情况下,
search-and-replace有 3 个关注者。我敢打赌 html 的追随者比这还多。当然,目标是让尽可能多的知识渊博的人看到您的问题。祝你好运!