From: Josh Cheek Date: 2011-07-23T04:28:21+09:00 Subject: Re: regex oddity --000e0cd56c5e05e47a04a8ad766d Content-Type: text/plain; charset=ISO-8859-1 On Fri, Jul 22, 2011 at 1:50 PM, Kendall Gifford wrote: > On Fri, Jul 22, 2011 at 12:41 PM, Roger Pack >wrote: > > > Anybody know why this occurs? > > > > >> 'a'.scan /.*/ > > => ["a", ""] > > > > Is this normal/expected? > > > > Not saying this is normal, but my suspicion is: > > #scan first matches "a" (whole string), then tries to match on remainder > ("") and matches (since '*' matches 0 character) giving you another match > of > "". > > Seems correct: "a".scan(/.*/) # => ["a", ""] "a".scan(/.+/) # => ["a"] --000e0cd56c5e05e47a04a8ad766d--