From: Joel VanderWerf Date: 2007-10-31T08:24:24+09:00 Subject: Re: Why, oh, why, little regexp? Daniel Waite wrote: > 'cost * tax'.match(/([a-z]+)*/).to_a > => ["cost", "cost"] > > Why? > > I'm reading it as... Take one or more characters between a and z, store > them into a back reference, then repeat the previous match zero or more > times. > > Now, that regexp doesn't do what I want it to do, but what it IS doing > doesn't make sense to me. > > What I'd like is to grab all the "words" in the string. So in the above > example I'd like two matches, cost and tax. > > Any ideas? 'cost * tax'.scan(/\w+/) => ["cost", "tax"] > PS: match(...).captures always, always returns an empty array... How are you using it? "foo".match(/(foo)/).captures => ["foo"] 'cost * tax'.match(/([a-z]+)*/).captures => ["cost"] -- vjoel : Joel VanderWerf : path berkeley edu : 510 665 3407