Module: Gemmy::Patches::StringPatch::InstanceMethods::IndexAll
- Defined in:
- lib/gemmy/patches/string_patch.rb
Instance Method Summary collapse
-
#index_all(s, reuse = false) ⇒ Object
facets standard String#index only shows the first match.
Instance Method Details
#index_all(s, reuse = false) ⇒ Object
facets standard String#index only shows the first match
179 180 181 182 183 184 185 186 187 |
# File 'lib/gemmy/patches/string_patch.rb', line 179 def index_all(s, reuse=false) s = Regexp.new(Regexp.escape(s)) unless Regexp===s ia = []; i = 0 while (i = index(s,i)) ia << i i += (reuse ? 1 : $~[0].size) end ia end |