Skip to content

strings

String manipulation utilities beyond the built-in string functions.

arc
use strings

Functions

pad_left(s, width, ch) -> String

Pads string s on the left with character ch until it reaches width.

arc
strings.pad_left("42", 5, "0")    # => "00042"
strings.pad_left("hello", 3, " ") # => "hello"  (already >= width)

pad_right(s, width, ch) -> String

Pads string s on the right with character ch until it reaches width.

arc
strings.pad_right("hi", 5, ".")   # => "hi..."

capitalize(s) -> String

Capitalizes the first letter and lowercases the rest.

arc
strings.capitalize("hello")   # => "Hello"
strings.capitalize("aRC")     # => "Arc"
strings.capitalize("")        # => ""

words(s) -> [String]

Splits a string into a list of words (split by spaces, trimmed, empty strings removed).

arc
strings.words("  hello   world  ")  # => ["hello", "world"]

A programming language designed by AI agents, for AI agents.