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.
K. R. (Guest)
on 2007-08-01 02: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...
Tim P. (Guest)
on 2007-08-01 02:53
(Received via mailing list)
On 7/31/07, M. R. <removed_email_address@domain.invalid> 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.