From: Robert Dober Date: 2009-07-15T22:06:09+09:00 Subject: Re: Search in string with regular expression On 7/15/09, Robert Dober wrote: > 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. I mean \B is not a word boundary and \b is a word boundary and I wonder WHAT I did test??? Sorry R.