partition

str.partition(sep) â [head, sep, tail]
str.partition(regexp) â [head, match, tail]
Instance Public methods

Searches sep or pattern (regexp) in the string and returns the part before it, the match, and the part after it. If it is not found, returns two empty strings and str.

"hello".partition("l")         #=> ["he", "l", "lo"]
"hello".partition("x")         #=> ["hello", "", ""]
"hello".partition(/.l/)        #=> ["h", "el", "lo"]
doc_ruby_on_rails
2015-05-15 18:06:13
Comments
Leave a Comment

Please login to continue.