filter - How to escape minus in regular expression with sed? -


i need free string unwanted characters. in example want filter +'s , -'s b , write result c. if b +fdd-dfdf+, c should +-+.

read b c=$(echo $b | sed 's/[^(\+|\-)]//g') 

but when run script, console says:

sed: -e expression #1, char 15: invalid range end

the reason \- in regular expression. how can solve problem , say, want filter -'s?

are looking this?

kent$ echo 'a + b + c - d - e'|sed 's/[^-+]//g' ++-- 

Comments

Popular posts from this blog

python - mat is not a numerical tuple : openCV error -

c# - MSAA finds controls UI Automation doesn't -

wordpress - .htaccess: RewriteRule: bad flag delimiters -