On Thu, 13 Mar 2003, Marius Ascheberg wrote:

> #!perl -p0
> s/^((\S+).+)\n\2/$1/m&&redo
> 
> 30 strokes, but I was not able to remove the redo.

very nice, but you broke it :-)

input:
this go
thises kablooey

output:
this goes kablooey

this works:
#!perl -p0
s/^((\S+ ).+)\n\2/$1 /m&&redo

here's another (equal length, stupid \Q :-)
this works since perl kindly resets the //g search upon modify.

#!perl -p0
s/\G\n\Q$1/ /while/(\S+ ).*/g

and if we ever get those variable length lookbehinds in perl:

#!perl -p0
s/(?<=^\1.+)\n(\S+ )/ /gm

or something thereabouts :-)

  -bass

Reply via email to