Categories: None [Edit]

match_all

https://rubygems.org/gems/match_all
https://github.com/jeffdlange/match_all
Ruby String's native #match method will only return the first instance of a pattern match. This gem provides the #match_all method, returns all instances of a pattern match in a String as an array. EXAMPLES: # Given the test string: string = "My cat is asleep on the couch. Now the cat is playing." # #match only returns the first match: string.match(/cat/) => # # However, I've found I often want to match _all_ instances of the pattern, and # then e.g. iterate through them and do something with them. #match_all does that: string.match_all(/cat/) => [ [0] #, [1] # ] This is especially useful if, e.g. you want to interrogate the matches to find out their starting/ending indexes within the string, etc

Total

Ranking: 174,206 of 180,671
Downloads: 1,394

Daily

Ranking: 46,716 of 180,660
Downloads: 7

Depended by

RankDownloadsName

Depends on

RankDownloadsName
24771,889,602rspec
63426,092,036pry

Owners

#GravatarHandle
1iconjeffdlange