2009/9/17 roger peppe <rogpe...@gmail.com>:
> just change the regexp as required.

Ok. I decided (although just for game now) to play a little with the
idea of building the regexp.
Starting from Eric's post I slowly progressed to sth. quite similar to
your post :) :

fn buildre {
       re = 's:^([      ]*)('
       for(i in `{seq 1 `{hoc -e $1-1}})
               re = $re ^ '[^   ]+[     ]+'
       re = $re ^ ')[^  ]+:\1\2' ^ $2:
}

This works (even takes care about leading spaces) unless I want to use
it for the 1st field. Then the produced regexp (buildre 1 hell)is

s:^([   ]*)()[^         ]+:\1\2hell:

and sed says
sed: Command garbled: s:^([     ]*)()[^         ]+:\1\2hell:

Apparently it dislikes the empty group, (). Is there any reason?
I tried it in linux, there with

echo '1 28              3' | sed 's:^\([        ]*\)\(\)[^      ][^     
]*:\1\2hell:'

and it works as expected...

Thanks
Ruda

Reply via email to