regex - sed error: "invalid reference \1 on `s' command's RHS" -


i run several substitution commands core of colorize script maven. 1 of sed commands uses regular expression works find in shell discussed here. current (not working) implementation can found here.

when include 1 of variants of command script different behavior occurs:

variant 1:

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

adapted script:

-re "s/warning: ([a-za-z0-9./\\ :-]+)/${warn}warning: \1${c_end}/g" \ 

error: shell outputs same information if type $ sed. strange!?


variant 2:

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

adapted script:

-e "s/warning: \([a-za-z0-9./\\ :-]\+\)/${warn}warning: \1${c_end}/g" \ 

error:

sed: -e expression #7, char 59: invalid reference \1 on `s' command's rhs

don't need capture work? i.e. variant 2:

-e "s/warning: (\([a-za-z0-9./\\ :-]\+\))/${warn}warning: \1${c_end}/g" \ 

(note: untested)


Comments

Popular posts from this blog

SPSS keyboard combination alters encoding -

Add new record to the table by click on the button in Microsoft Access -

javascript - jQuery .height() return 0 when visible but non-0 when hidden -