请有人帮忙。我需要查找和删除特定HTML标记中的逗号,例如< H3>和< H4>在命令行中但仅来自此标记。
示例:
...
<h3>Sample header, with some, text with commas</h3>
<h4>Sample header, with some, text with commas</h4>
<p>Loreipsum sit amet, dolor...</p>
...
我使用:
sed "/<h3>/,/<\/h3>/s/,//g"
但是此命令从所有代码中删除逗号...我只需要来自&lt; H3&GT;和&lt; H4&GT;标签
答案 0 :(得分:0)
你可以试试这个
sed -e '/<*>/s/,/ /g' stack4.html
在stack.html下面的字符串写成
<h3>Sample header, with some, text</h3>
Hi, what's your namiue
<h3>Sample header, with some, text</h3>
<h3>Sample header, with some, text</h3>
hyt,ujt,yj
<h3>Sample header, with some, text</h3>
jkj<h3>Sample header, with some, text</h3>
我/我得到了
<h3>Sample header with some text</h3>
Hi, what's your namiue
<h3>Sample header with some text</h3>
<h3>Sample header with some text</h3>
hyt,ujt,yj
<h3>Sample header with some text</h3>
jkj<h3>Sample header with some text</h3>
如果你只想为h3和h4做,那么下面的命令可能会帮助你
sed -e '/<h[3-4]>/s/,/ /g' stack4.html
希望它能奏效:)