Method: String#between
- Defined in:
- lib/casual_support/string/between.rb
#between(open, close) ⇒ String?
Returns the portion of the String between the first occurrences of an open
delimiter and a close
delimiter. If either delimiter is not found, returns nil.
14 15 16 17 18 19 20 21 |
# File 'lib/casual_support/string/between.rb', line 14 def between(open, close) i = self.index(open) if i i += open.length j = self.index(close, i) self[i, j - i] if j end end |