String functions
to_uppercase
Converts the string to uppercase lettering. upper
is an alias for to_uppercase
.
to_lowercase
Converts the string to lowercase lettering. lower
is an alias for to_lowercase
.
trim
Removes leading and trailing spaces and new line characters from the string.
capitalize
Capitalizes the first letter of the string.
underscore
Converts the string to "snake_case" formatting. to_snake_case
is an alias for underscore
.
camelize
Converts the string to "CamelCase" formatting.
empty
Returns true if the string is empty (length 0). blank
and is_empty
are aliases for empty
.
len
Returns the length of the string.
urldecode
Replaces percent-encoding in the string with its ASCII character equivalents. Commonly used to send characters with special meaning inside URLs.
urlencode
Opposite of urldecode
. Replaces ASCII characters with special meaning in URLs with percent-encoded strings.
br
Replaces new line characters in the string with <br>
. Also escapes all HTML tags.
replace
Replaces a value inside the string with another value. sub
is an alias for replace
.
This method accepts all data types, but it does convert them to their string representation before performing the replacement. For example, a string can be replaced with an integer:
title
Converts the string to "Title Case" formatting.