From: renton.dan@... Date: 2008-10-04T01:08:36+09:00 Subject: Re: Explain this ruby regex On Oct 3, 11:44 am, Ben Bleything wrote: > On Sat, Oct 04, 2008, renton....@gmail.com wrote: > > "one two".scan(/\w*/).length > > > returns 4. I can see it matching the 2 words and the space, what else > > is it matching on? Is there a null terminator, I thought Ruby strings > > were not null termed. > > Try replacing #length with #inspect and seeing what the output of scan > is.  You'll find that it's returning two empty strings as well.  I > suspect what you really want is \w+... > > Ben Yeah, you're right \w+ will pull out the words, which is what I want anyway. Though I'm trying to understand what \w* is doing. irb(main):015:0> "one two".scan(/\w*/).inspect => "[\"one\", \"\", \"two\", \"\"]" My question is, what is the last "\", where does it come from.