On 13 March 2010 01:39, erik quanstrom <quans...@labs.coraid.com> wrote: >> Ok, thats fine. But >> ;9 echo abcdefdffghi | 9 sed 's/(abc(d?f)*)(ghi)/\1/' >> >> this I don't understand... >> maybe it's too late for me... > > you're re doesn't match at all. therefore no > substitutation is made. perhaps it would be > easier to see with this formulation: >
Yes. Of course. I was just really tired at the point to not notice... Actually, what I was trying to check was ;9 echo abcdefdffghi | 9 sed 's/(abc(d.?f)*)(ghi)/\6/' sed: Invalid back reference \6 ;9 echo abcdefdffghi | 9 sed 's/(abc(d.?f)*)(ghi)/\1/' abcdefdff ;9 echo abcdefdffghi | 9 sed 's/(abc(d.?f)*)(ghi)/\2/' dff ;9 echo abcdefdffghi | 9 sed 's/(abc(d.?f)*)(ghi)/\3/' ghi ; i.e. not just '?' but '.?' to see what will be where in \1, \2... And the above shows, hopefully now, that for construction like (regexp)* the last match is stores in the corresponding (here) \2. And the order of \1, \2, ... ($1, $2... for the plumber then) is determined by the opening (. Thanks Ruda