String API Reference
Ruby's String — a mutable sequence of bytes holding characters, with a rich set of methods.
String
A String object holds and manipulates an arbitrary sequence of bytes, typically representing characters.
String#length -> IntegerReturns the number of characters in the string.
Returns: Integer
String#upcase -> StringReturns a copy of str with all lowercase letters replaced with their uppercase counterparts.
Returns: String
String#downcase -> StringReturns a copy of str with all uppercase letters replaced with their lowercase counterparts.
Returns: String
String#split(pattern=nil, [limit]) -> ArrayDivides str into substrings based on a delimiter, returning an array of substrings.
Returns: Array
String#gsub(pattern, replacement) -> StringReturns a copy of str with all occurrences of pattern substituted with replacement.
Returns: String
String#strip -> StringReturns a copy of str with leading and trailing whitespace removed.
Returns: String
String#include?(substring) -> boolReturns true if str contains the given string or character.
Returns: Boolean
String#chars -> ArrayReturns an array of characters in str.
Returns: Array