我有一根看起来像这样的绳子。
<tag-name i-am-an-attribute="123" and-me-too="321">我想要做的就是把虚线替换成下划线,但是标签名应该保持不变。
希望有一些专家能帮我解决问题。
如果有人需要这个解决方案。
我最后得到了perl oneliner命令。
echo '<tag-name i-am-an-attribute="123" and-me-too="321">' | perl -pe 's/( \K[^*"]*)-/$1_/g;' | perl -pe 's/ / /g;'
结果:
<tag-name i_am_an_attribute="123" and_me_too="321">发布于 2013-11-22 19:08:50
使用sed:
sed ':l;s/-\([^- ]*\)\( *=\)/_\1\2/g;tl' input给予:
<tag-name i_am_an_attribute="123" and_me_too="321">https://stackoverflow.com/questions/20147632
复制相似问题