THE JOA LANGUAGE

String Methods

Joa string method reference: case conversion, trimming, searching, splitting, replacing, and Unicode length.

Methods are called with dot notation followed by parentheses: value.method(args).

length is a property (no parentheses); all others are methods (require ()).

Method / Property Returns Description
s.length Integer Number of characters (Unicode-aware)
s.upper() String Uppercase copy
s.lower() String Lowercase copy
s.trim() String Removes leading and trailing whitespace
s.contains(sub) Bool Whether the string contains the substring
s.split(sep) List Splits on separator; defaults to a single space
s.starts_with(prefix) Bool Whether the string starts with the given prefix
s.ends_with(suffix) Bool Whether the string ends with the given suffix
s.replace(old, new) String Replaces all occurrences of old with new
s.index_of(sub) Integer UTF-8 byte offset of first occurrence, or -1 if not found
let name = "  Joa Language  "

print(name.trim())                      // "Joa Language"
print(name.trim().upper())              // "JOA LANGUAGE"
print(name.trim().lower())              // "joa language"
print(name.trim().contains("Lang"))     // true
print(name.trim().split(" "))           // [Joa, Language]
print(name.trim().starts_with("Joa"))   // true
print(name.trim().ends_with("e"))       // true
print(name.trim().replace("Joa", "Go")) // "Go Language"
print(name.trim().index_of("L"))        // 4
print(name.length)                      // 16 (includes spaces)

Method calls can be chained:

let clean = raw_input.trim().lower().replace("-", "_")

len(s), s.length, and string indexing count Unicode code points, not grapheme clusters. index_of() uses a byte offset instead, so its result may differ from a character index for non-ASCII text. For example, "éa".index_of("a") returns 2, while "éa"[1] returns "a".