in reply to Regex catching multiple characters next to each other
If you're interested in the count, try this approach:
#!/usr/bin/perl use v5.14; $_ = 'LLL'; my @matches = m/(L)(?=L)/g; say scalar @matches; #prints 2, as expected
The (L)(?=L) expression looks for every 'L' immediately followed by another 'L'. As there are two such matches, the @matches array contains two elements.
regards,
Luke Jefferson
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re^2: Regex catching multiple characters next to each other
by AnomalousMonk (Archbishop) on Oct 06, 2014 at 13:04 UTC | |
by blindluke (Hermit) on Oct 06, 2014 at 20:12 UTC |