From: Rajkumar Surabhi Date: 2010-03-12T21:23:45+09:00 Subject: Re: how to get word from sentence thanxs how to get the first word matches the expresion if i have no of words which matches. Jes炭s Gabriel y Gal叩n wrote: > On Fri, Mar 12, 2010 at 11:48 AM, Rajkumar Surabhi > wrote: >> Hi all, >> In my application i have to get the word which contains given word. >> example >> sentence: iam testung the aplication >> i want to extract the word which starts with test >> how to do this > > You can do it with a regular expression. Here is an example: > > irb(main):001:0> s = "i am testing the app" > => "i am testing the app" > irb(main):004:0> s[/\btest\w*/] > => "testing" > > \b --> word boundary > \w --> word character > > Jesus. -- Posted via http://www.ruby-forum.com/.