R – sed to replace random site urls in ifrrame

iframeregexsedsh

my problem there is alot of pages infacted with iframe each one of them have different url or different id
here is example

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

or

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

where all xxx are random some times
what i need to do is to remove,replace this iframe with blank
like this

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

sorry about my bad english
thanks in advance

Best Solution

The question is not very clear but from what I understand you want to remove all iframes with the style="visibility:hidden" from the file.

Something like this should work for you:

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

...or a bit more specific:

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