Method: String#after_last
- Defined in:
- lib/casual_support/string/after_last.rb
#after_last(delimiter) ⇒ String?
Searches for the last occurrence of delimiter
, and returns the portion of the String after that. If delimiter
is not found, returns nil. Equivalent to split(delimiter, -1).drop(1)[-1]
for non-empty delimiters.
15 16 17 18 |
# File 'lib/casual_support/string/after_last.rb', line 15 def after_last(delimiter) i = self.rindex(delimiter) i && self[i + delimiter.length, self.length] end |