Forum: Ruby find search word within a string

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
C0dd31d9c6d343ca4ec4428a7a76ace7?d=identicon&s=25 K. R. (ribit)
on 2007-08-01 00:44
Hi @ all

I would like to search in a string a user-defined word and I want to
find out, how many times its appear in the string. Can anyone help me?

thanks for your effort...
4d5b5dd4e263d780a5dfe7ac8b8ac98c?d=identicon&s=25 Tim Pease (Guest)
on 2007-08-01 00:53
(Received via mailing list)
On 7/31/07, M. R. <ribi@schwingerverband.ch> wrote:
> Hi @ all
>
> I would like to search in a string a user-defined word and I want to
> find out, how many times its appear in the string. Can anyone help me?
>

String#scan

Please read the documentation for details.

Blessings,
TwP
This topic is locked and can not be replied to.