From: Wilson Bilkovich Date: 2006-12-07T06:02:55+09:00 Subject: Re: Get Number of regex matches On 12/6/06, Ingo Weiss wrote: > Hi, > > how can I get the NUMBER of matches for a regular expression in a given > string? > > For example: for string 'Banana' and regex /a/ I should get '3' > (matches) > One way is: 'Banana'.scan(/a/).size I'm not sure how to get it out of the MatchData returned by 'match' or =~, unfortunately.