Skip to content

String Functions

Uppercase and Lowercase

:uppercase(text)

Converts the text to uppercase.

@name = john
:uppercase(@name)  # Result: JOHN

:lowercase(text)

Converts the text to lowercase.

@name = JOHN
:lowercase(@name)  # Result: john

:capitalize(text)

Capitalizes the first letter of the text.

@name = john smith
:capitalize(@name)  # Result: John smith

String Manipulation

:trim(text)

Removes whitespace from the beginning and end of the text.

@text = "  hello world  "
:trim(@text)  # Result: "hello world"

:replace(text, search, replacement)

Replaces occurrences of a substring with another.

@text = hello world
:replace(@text, world, ILLEX)  # Result: hello ILLEX