Re: counting regex matches

2001-06-14 Thread Michael Fowler
On Thu, Jun 14, 2001 at 05:08:30PM -0400, Carl Rogers wrote: > > > > >$string =~ /a/g; # match on all 'a' in $string > > > >Now how do I know how many times it actually matched? > > Try: > $result = $string =~ /a/g; > The value will be in $result > perl -wle '$str = "abcabcabc"; $cnt = $str

Re: counting regex matches

2001-06-14 Thread Sean O'Leary
Oops! Sorry! Wrong section of the documentation. I meant to grab the paragraph a little further down. Still in perlop, still in the Regexp Quote-Like Operators section: The /g modifier specifies global pattern matching--that is, matching as many times as possible within the string. How i

Re: counting regex matches

2001-06-14 Thread Sean O'Leary
At 05:08 PM 6/14/2001, you wrote: >Try: >$result = $string =~ /a/g; >The value will be in $result > >Carl Close. You have to force list context for the result of the pattern match to make it work. Like this: $result = () = $string =~ /a/g; (Thanks to Mark-Jason Dominus) Check out perlop for

RE: counting regex matches

2001-06-14 Thread Wagner-David
Original Message- From: Carl Rogers [mailto:[EMAIL PROTECTED]] Sent: Thursday, June 14, 2001 14:09 To: [EMAIL PROTECTED]; [EMAIL PROTECTED] Subject: Re: counting regex matches > >$string =~ /a/g; # match on all 'a' in $string > >Now how do I know how many times it actua

Re: counting regex matches

2001-06-14 Thread Carl Rogers
> >$string =~ /a/g; # match on all 'a' in $string > >Now how do I know how many times it actually matched? Try: $result = $string =~ /a/g; The value will be in $result Carl

counting regex matches

2001-06-14 Thread Bob Mangold
Is there a simple way to know how many times a regex matches. Say for example: $string =~ /a/g; # match on all 'a' in $string Now how do I know how many times it actually matched? -Bob __ Do You Yahoo!? Get personalized email addresses from Yahoo