http://www.perlmonks.org?node_id=478050


in reply to Re: Capture Lookahead
in thread Capture Lookahead

First, I must say I think I've seen what I want to achieve here in some other post but I don't know how to find it now - was posted several months ago.

An example would be:

String of: ABCDEFGHIJK

and, on one pass, I would like to capture the substrings (of some arbitrary length)

ABCDEF
BCDEFG
CDEFGH
DEFGHI
EFGHIJ
FGHIJK
Further, on every pass, I want to decrease the length of the strings to be captured by 1 until the outer while loop bails out.

Thanks for the note on my error concerning pos $str.

Hope this makes the problem clearer.

Chris

Replies are listed 'Best First'.
Re^3: Capture Lookahead
by GrandFather (Saint) on Jul 26, 2005 at 02:25 UTC

    In that case you don't want a regex at all. Use substr.


    Perl is Huffman encoded by design.