BETAmodules.com is in beta — open to partnerships & joint ventures.Build with us

match_all

v0.1.2RubyGems· Ruby

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/) => #<MatchData "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] #<MatchData "cat">, [1] #<MatchData "cat"> ] This is especially useful if, e.g. you want to interrogate the matches to find out their starting/ending indexes within the string, etc

The verdict
Abandoned. Last published 3 years ago. No recent activity — look for a maintained alternative.
No recent activity — look for a maintained alternative.
Live from the RubyGems registry · derived rules, not AI
How it scores
MaintenanceAbandoned
PopularityNiche
SecurityClean
LicensePermissive
DepsZero deps
Maintenance
Last published 3 years ago.
Popularity
5 downloads / week
Security
No known advisories for this version (OSV).
License
MIT
Dependencies
No runtime dependencies
Recent releases
  • 0.1.23 years ago
  • 0.1.13 years ago
  • 0.1.03 years ago
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/) => #<MatchData "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] #<MatchData "cat">, [1] #<MatchData "cat"> ] This is especially useful if, e.g. you want to interrogate the matches to find out their starting/ending indexes within the string, etc (Ruby / RubyGems) · Modules