使用 sed 命令替换字符串 [英] Replacing a string using sed command

查看:63
本文介绍了使用 sed 命令替换字符串的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用 sed 命令匹配我的 html 文件中以 &# 开头的字符串并将其替换为空格?

How to use sed command to match strings starting with &# in my html file and replace it with space ?

  • 示例:&#192
  • 结果:空格
  • 应该完全被空格代替

它应该适用于 &# 后有 3 或 4 位数字的所有 HTML 代码.

It should work for all the HTML codes with three or 4 digits trailing &#.

基本上是 HTML 代码:http://webdesign.about.com/library/bl_htmlcodes.html

Basically HTML codes: http://webdesign.about.com/library/bl_htmlcodes.html

推荐答案

明白了 sed -e 's_&#[0-9]*_ _g'

这篇关于使用 sed 命令替换字符串的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆