Jeri has asked for the wisdom of the Perl Monks concerning the following question:
Hi,
If I have a string "LLL" and I want to capture a count of how many times "LL" occurs, I would expect the count to be 2, but in the way my regular expression is written I'm getting a count of only 1. Do I have to use seek to get the appropriate count? Here's what I've written. How can I get it to recognize the last two LLs as a pair?
my @matches = ($_=~m/.*("LL").*/g); if(@matches){foreach(@matches){$counter++;}}
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Regex catching multiple characters next to each other
by roboticus (Chancellor) on Oct 06, 2014 at 06:05 UTC | |
|
Re: Regex catching multiple characters next to each other
by blindluke (Hermit) on Oct 06, 2014 at 06:05 UTC | |
by AnomalousMonk (Archbishop) on Oct 06, 2014 at 13:04 UTC | |
by blindluke (Hermit) on Oct 06, 2014 at 20:12 UTC | |
|
Re: Regex catching multiple characters next to each other
by Laurent_R (Canon) on Oct 06, 2014 at 06:11 UTC | |
|
Re: Regex catching multiple characters next to each other
by AnomalousMonk (Archbishop) on Oct 06, 2014 at 12:54 UTC |