|
|
| more useful options | |
| PerlMonks |
Re: Longest possible run of a single characterby Zaxo (Archbishop) |
| on May 22, 2006 at 21:26 UTC ( #551041=note: print w/ replies, xml ) | Need Help?? |
|
It's simpler than that, just use regex greediness. You were very close. Here's an example, That skips capturing lone characters as a sequence of one - change the '+' quantifier to '*' to get them, too. There is no practical limit on the length of the match. I didn't address picking out the maximum length substring captured. There are lots of ways to do that. Update: Ok, here's an easy way to get the max length as the search is done, using the (?{}) construct. Access to the original matching chunk of the string is given by substr($_, $maxloc, $maxlen). After Compline,
In Section
Seekers of Perl Wisdom
|
|
||||||||||||||||||||||||