Beefy Boxes and Bandwidth Generously Provided by pair Networks
Pathologically Eclectic Rubbish Lister
 
PerlMonks  

Re^3: Capture Lookahead

by GrandFather (Cardinal)
on Jul 26, 2005 at 02:25 UTC ( #478053=note: print w/ replies, xml ) Need Help??


in reply to Re^2: Capture Lookahead
in thread Capture Lookahead

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

use strict; use warnings; my $str = do {local $/; <DATA>}; $str =~ s/\s+//g; my $len = length $str; for (my $width = 5; $width; --$width) { for (0..($len - $width)) { print substr ($str, $_, $width) . "\n"; } } __DATA__ ABCDEFGHIJK
ABCDE BCDEF CDEFG DEFGH EFGHI FGHIJ GHIJK ABCD BCDE CDEF DEFG EFGH FGHI GHIJ HIJK ABC BCD CDE DEF EFG FGH GHI HIJ IJK AB BC CD DE EF FG GH HI IJ JK A B C D E F G H I J K

Perl is Huffman encoded by design.


Comment on Re^3: Capture Lookahead
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://478053]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others exploiting the Monastery: (5)
As of 2014-12-20 18:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (97 votes), past polls