0

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

  • Example: &#192
  • Result: space
  • Should be completely replaced by space

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

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

4

4 回答 4

2
$ sed 's/\&#[0-9]*/ /g' your
于 2012-09-11T07:30:25.990 回答
0
> echo "&#192" | sed -e 's_&#_ _g'
 192

在 perl 中:

> echo "&#192" | perl -pe 's/&#/ /g'
 192

在 awk 中:

> echo "&#192" | awk '{gsub(/&#/," ");print}'
 192
于 2012-09-11T05:54:47.370 回答
0

您可以像这样替换

abc="&#192"
echo $abc | sed 's/\&\#/ /g'
于 2012-09-11T05:41:18.817 回答
0

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

于 2012-09-11T07:39:15.707 回答