RubyGems Navigation menu

match_all 0.1.2

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

Gemfile:
= 複製 已複製

安裝:
=

版本列表:

  1. 0.1.2 - November 15, 2022 (8.5 KB)
  2. 0.1.1 - November 11, 2022 (7.5 KB)
  3. 0.1.0 - November 11, 2022 (7.5 KB)

Development 相依性套件 (2):

pry ~> 0.13.1
rspec ~> 3.2

擁有者:

Pushed by:

作者:

  • Jeff Lange

SHA 256 checksum:

1166658161e9865ec8adac49abdaf673736af8ab238a8f468ff5ef926d730121

總下載次數 1,411

這個版本 585

License:

MIT

Ruby 版本需求: >= 2.6.0

相關連結: