Beefy Boxes and Bandwidth Generously Provided by pair Networks
There's more than one way to do things
 
PerlMonks  

Re: How can I use backrefs in a lookbehind?

by Ieronim (Friar)
on Jun 28, 2006 at 21:51 UTC ( [id://558162]=note: print w/replies, xml ) Need Help??


in reply to How can I use backrefs in a lookbehind?

Only a small remark:
The idea of variable-length lookbehind is very good, but the given problem can be solved even without using lookbehinds at all:
#!/usr/bin/perl use warnings; use strict; my $pat = qr{ ( # 1: capture the whole substring (?: (.) # a character (?!\2\2) # NOT repeated three times ){1,4} # one to four of such 'good' characters .. # two any characters more; 2+4 = 6 ) }x; foreach (qw/AABBCCDD AABBBCCD AAABBCCD AABBCCCD AAABCDE/) { print "$1\n" if /$pat/; }
outputs
AABBCC AABB AABBCC AABBCC AABCDE

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others wandering the Monastery: (3)
As of 2024-04-25 14:46 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found