From: Robert Dober Date: 2009-07-15T22:03:52+09:00 Subject: Re: Search in string with regular expression On 7/15/09, Harry Kakueki wrote: >> Maybe >> str2 = str1.scan( /\bfrog\w*\B/ ).join(" ") >> that is if you want to match frog at the start of words only (\b) and >> assure charcters of your choice up to the end of the word? As \w might >> be a little bit too permissive, in 1.9 you might prefer >> str2 = str1.scan( /\bfrog[[:alpha:]]*\B/ ).join(" ") >> and all those nice variations ;) >> >> HTH >> Robert >> >> >> > Or maybe, :) > > str2 = str1.scan( /\bfrog\w*\b/ ).join(" ") No it was not a typo, I thought that \B was matching at the end of the word, I did not test with a frog at the end. I stand corrected \B does not have a special meaning and \b is just a word boundary. Thx Robert > A Look into Japanese Ruby List in English > http://www.kakueki.com/ruby/list.html > > -- Toutes les grandes personnes ont d’abord été des enfants, mais peu d’entre elles s’en souviennent. All adults have been children first, but not many remember. [Antoine de Saint-Exupéry]