Re: RFC 110 (v2) counting matches
[email protected] (Bart Lateur)
| Newsgroups | perl.perl6.language.regex |
|---|---|
| Organization | MediaMind |
| Message-ID | <[email protected]> |
On 27 Aug 2000 19:01:45 -0000, Perl6 RFC Librarian wrote:
>m//g just returns 1 for matching.
Er... but in a scalar context, m//g DOES only match once! If you want
more, repeat the match. Or use it in a list context, then it will try to
match them all.
$_ = "abaabbbababbbabbaaa";
while(/(b+)/g) {
print "Got a '$1'\n";
}
-->
Got a 'b'
Got a 'bbb'
Got a 'b'
Got a 'bbb'
Got a 'bb'
Let's try again:
$_ = "abaabbbababbbabbaaa";
print scalar(() = /b+/g);
-->
5
Is that what you're after?
--
Bart.