I want to extract patterns that appert multiple times in a string. For example,getting two an array lay of two digit integers from a string
wahoaet56oihaioet67jlkiwoeah67ladohwae45lkaowearho56
I thought
result="wahoaet56oihaioet67jlkiwoeah67ladohwae45lkaowearho56".match(/([0-9]{2})/)
should give a MatchData object whose captures
method should give me an array of matched patters, but it seems there is something I am missing. It only give back the first find. Even using $1,$2,$3
etc doesn't work. I am using ruby
How should I do this?
string.scan(/regex/)
should do it
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With