From: Jim Burgess Date: 2009-09-28T03:13:34+09:00 Subject: Re: Regular expression question Vielen Dank f端r deine Antwort :-) I was unaware that the reg ex would start from the point where it encounters the first character satisfying \w. Regular expressions - sometimes I hate them more than I love them. Thanks very much for your help. > Eine kleine Misverstaendnis :-) > > \w+ means "one or more from the set (alphanumeric + underscore)". > The pattern will start trying to match at the beginning of the string, > where it finds \w+, then the space, then more \w+. It grabs all of Ein > because it hasn't found a space yet (but it also hasn't found any > reason to stop proceeding along the string, since "E", "Ei", and "Ein" > are all \w+). It only grabs the k in kleiner because that satisfies > the pattern in non-greedy fashion. > > In this particular case, the first + doesn't matter, because the > pattern will keep going until it finds a space, so normal rules of > (non-)greediness don't apply. > > > David -- Posted via http://www.ruby-forum.com/.