Welcome to the Monastery | |
PerlMonks |
comment on |
( [id://3333]=superdoc: print w/replies, xml ) | Need Help?? |
Contrary to what jcwren says, I would hardly label myself a regex guru, but thanks for the compliment :)
As far as I can tell, you can't use the match operator to return the length. The closest I came up with is a variation of Ozymandias' response: In the Perl Cookbook, it has a recipe for finding the nth occurence of a match, but that also uses a loop. If you could enumerate matches with a straight regex, you could construct a well-defined regex and skip the loop in the Cookbook. Believe me, I tried :) If any monks would like to tackle this, I'd love to be proven wrong (and I'm sure it would be something ridiculously simple). Update: And in my quest to come up with horribly unoptimized code: Or you can use this beauty (no, I'm not serious): No, I don't suggest using them. I just had to toss it out because no one else had mentioned it :) In reply to RE: RE: Counting Characters
by Ovid
|
|