in reply to Re: Getting the number of times a regexp matches
in thread Getting the number of times a regexp matches

I don't think that the second one will be correct for strings like "blue blue blue and blue again" and patterns like "^blue"...

Update: Sorry mirod, I misread that one :)

Lets all have a try at it:
@_=($str =~ m/$pattern/g) and $count=1+$#_;


/brother t0mas

Replies are listed 'Best First'.
Re: Re: Re: Getting the number of times a regexp matches
by mirod (Canon) on Dec 07, 2000 at 15:47 UTC

    Actually it is, $count gets set to 1