DOCUMENTATION

String Methods

DOCUMENTATION

XCX 4.4.1 String Methods

String objects in XCX are immutable. Methods return a new string and do not modify the original.

Properties

  • .length: Returns the number of Unicode code points in the string (e.g., "zażółć".length is 6). Used without parentheses.

Escape Sequences

String literals support standard escape sequences:

SequenceEffect
\nNewline
\tHorizontal Tab
\rCarriage Return
\"Double Quote
\\Backslash
\xNNHexadecimal character (e.g., \x1b)
\NNNOctal character (e.g., \033)

Methods

MethodSignatureDescription
.upper()() → sConverts all characters to uppercase.
.lower()() → sConverts all characters to lowercase.
.trim()() → sRemoves leading/trailing whitespace.
.replace(f, t)(s, s) → sReplaces all occurrences of f with t.
.slice(s, e)(i, i) → sReturns substring from index s up to e.
.indexOf(s)(s) → iReturns index of first occurrence, or -1.
.lastIndexOf(s)(s) → iReturns index of last occurrence, or -1.
.startsWith(s)(s) → bReturns true if string starts with s.
.endsWith(s)(s) → bReturns true if string ends with s.
.toInt()() → iParses string to Integer; halt.error if fail.
.toFloat()() → fParses string to Float; halt.error if fail.
.split(s)(s) → array:sSplits by separator s; returns array of strings.

Examples

$ xcx
_ ⛶ ×
1s: raw = " XCX-Language ";
2s: clean = raw.trim().lower().replace("-", "_"); --- "xcx_language"
3
4i: start = "Programming".indexOf("gram"); --- 3
5s: part = "Programming".slice(0, 4); --- "Prog"
6
7i: age = "25".toInt();
8array:s: parts = "a,b,c".split(","); --- {"a", "b", "c"}