【问题标题】:sed to replace random site urls in ifrramesed 替换 iframe 中的随机站点 url
【发布时间】:2010-11-05 05:34:48
【问题描述】:

我的问题有很多页面都使用 iframe,每个页面都有不同的 url 或不同的 id 这是示例

<iframe src="http://xxxxxx.xxxx/xxxx.xxx" width=xxx height=xxx style="visibility: hidden"><iframe>

<iframe src="http://xxxxxx.xxxx/xxxx.xxx?xxx=xxxx" width=xxx height=xxx style="visibility: hidden"><iframe>

有时所有 xxx 都是随机的 我需要做的是删除,用空白替换这个 iframe 像这样

sed -i 's%<iframe src="xxx://xxxxxx.xxxx/xxxx.xxx?xxx=xxxx" width=xxx height=xxx style="visibility: hidden"><iframe>%%g' file

对不起我的英语不好 提前致谢

【问题讨论】:

  • 好的,现在有什么问题?

标签: regex iframe sed sh


【解决方案1】:

这个问题不是很清楚,但据我了解,您想从文件中删除所有 style="visibility:hidden" 的 iframe。

这样的东西应该适合你:

sed -i 's%<iframe[^>]+style="visibility: hidden"></iframe>%%g' file

...或者更具体一点:

sed -i 's%<iframe src="[^"]+" width=[a-z0-9%]+ height=[a-z0-9%]+ style="visibility: hidden"></iframe>%%g file

【讨论】:

  • 感谢您的辛勤工作,问题是所有 xxx 有时都是随机的(我需要做的是删除,将此 iframe 替换为空白)
猜你喜欢
  • 2010-11-03
  • 2012-06-24
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2017-03-19
  • 1970-01-01
  • 2020-09-22
  • 2021-02-20
相关资源
最近更新 更多