D
Daniel Waite
'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?
PS: match(...).captures always, always returns an empty array...
=> ["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?
PS: match(...).captures always, always returns an empty array...