RegEx, How to get all matches and group? Ruby 1.9.3p125 -
let's have following string:
google-com, awesome-net(ooops), facebook-com / rocket-yet i want extract words ending -com have them grouped.
for now, have tried:
^\w+[-]com that works fine catches first match. how others? maybe using parentheses can't figure out how to..
having matched strings matchdata object (ruby) can work array.
i'm using ruby 1.9.3p125
1.9.3p125 :124 > original => "google-com, awesome-net(ooops), facebook-com / rocket-yet" 1.9.3p125 :125 > results = original.match(/(\w+-com)/) => #<matchdata "google-com" 1:"google-com">
Comments
Post a Comment