【发布时间】:2014-05-24 15:55:25
【问题描述】:
我有以下 perl 搜索和替换:
带有转义:
perl -pi -w -e 's/ onclick=\"img=document.getElementById(\'img_1\')\; img.style.display = (img.style.display == \'none\' ? \'block\' : \'none\');return false"//' test.html
没有转义:
perl -pi -w -e 's/ onclick="img=document.getElementById('img_1'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false"//' test.html
我的目标是用文件test.html 中的任何内容替换onclick="img=document.getElementById('img_1'); img.style.display = (img.style.display == 'none' ? 'block' : 'none');return false"。我在搞砸什么?
我不断收到错误:-sh: syntax error near unexpected token)'`,我不禁觉得这是因为我的一些愚蠢的逃避。请帮帮我。
【问题讨论】:
-
perl -pi -w -e 's/ onclick=\"img=document.getElementById(q{img_1}); img.style.display = (img.style.display == \'none\' ? \'block\' : \'none\');return false"//' test.html????没用。
标签: html regex perl shell replace