regex - sed error "Invalid range end" -


i run substitution command on ubuntu 12.04.

$ sed -e "s/([a-za-z0-9.-/\\ :]+)/\1/g" 

however, following error raised.

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

i can remember same expression works on macosx.
can describe why command fails?

you can solve in 2 ways. 1 of them use -r switch avoid escaping special characters , move - in range first or last position , avoid special meaning, like:

sed -re "s/([a-za-z0-9./\\ :-]+)/\1/g" 

otherwise need escape either (, ) , +, like:

sed -e "s/\([a-za-z0-9./\\ :-]\+\)/\1/g" 

Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Socket.connect doesn't throw exception in Android -

iphone - How do I keep MDScrollView from truncating my row headers and making my cells look bad? -