Front page | perl.golf |
Postings from January 2007
Re: simple golf for fun
Thread Previous
|
Thread Next
From:
Daniel Tiefnig
Date:
January 17, 2007 04:42
Subject:
Re: simple golf for fun
Message ID:
45AE139E.9000706@gmx.at
Ton Hospel wrote:
> -p0 s/\G(.*)(.* )(?=\1.\2|$)//g
>
> This should be about as efficient as a simple regex approach gets.
> It's also the shortest yet :-) It outputs starting from the first
> line that can't be extended. No output means all lines work.
If you're free to output whatever you want on mismatch, you can also
just omit the "\G".
-p0 s/\G(.*)(.*
)(?=\1.\2|$)//g
Will print all lines that preceed invalid changes. (As requested!) One
can create files that will make some problems, though. If a line does
not add at least one character, strange things may happen. But I think
it will always output something.
And until someone proves the contrary, I consider this being the
shortest solution so far. :o)
lg,
daniel
Thread Previous
|
Thread Next