But there is a trickier question (not in my text) which is to have the window start BEFORE the beginning of the string and end AFTER the end of the string. That means, with the same string and N, you would get "r", "re", "reg", "ege", "gex", "exe", "xes", "es", "s". That is more difficult, and sadly, bleadperl gave me grief when I tried to solve this problem with a regex using (??{ ... }). So I extend this challenge to you.
Given: string in $_, chunk size in $s (or any other variable you wish)
Golf: extract all overlapping substrings of at least 1 and at most $s characters from the string
Known: the string is at least 1 character long, but MAY be shorter than $s characters
Here is my attempt:
|
_____________________________________________________
Jeff[japhy]Pinyan:
Perl,
regex,
and perl
hacker.
s++=END;++y(;-P)}y js++=;shajsj<++y(p-q)}?print:??;
|
---|
Replies are listed 'Best First'. | |
---|---|
Re (tilly) 1: (Golf) Character windows
by tilly (Archbishop) on Aug 24, 2001 at 04:58 UTC | |
by japhy (Canon) on Aug 24, 2001 at 06:40 UTC | |
(MeowChow) Re: (Golf) Character windows
by MeowChow (Vicar) on Aug 24, 2001 at 22:01 UTC | |
Re: (Golf) Character windows
by chipmunk (Parson) on Aug 25, 2001 at 01:26 UTC | |
by MeowChow (Vicar) on Aug 25, 2001 at 01:35 UTC | |
by petral (Curate) on Sep 13, 2001 at 02:22 UTC | |
Re: (Golf) Character windows
by dfog (Scribe) on Aug 28, 2001 at 03:29 UTC |