From: "Wolfgang Nádasi-Donner" Date: 2007-11-18T23:56:43+09:00 Subject: Re: Count substrings from a string Zangief Ief wrote: > Hi, > > I am able to know if there is a substring in a string with: > > if string =~ /#{word}/: > puts "match" > else > puts "do not match" > end > > But I would like to count all the substring from a string... > > Thanks for help :) irb(main):001:0> "one word is one word, never be three words".scan(/word/).length => 3 :-), Wolfgang Nádasi-Donner -- Posted via http://www.ruby-forum.com/.