Skip to content

String

Pipe-friendly string operations.

FunctionSignatureDescription
String.trimstring -> stringRemove whitespace from both ends
String.trimStartstring -> stringRemove leading whitespace
String.trimEndstring -> stringRemove trailing whitespace
String.splitstring, string -> Array<string>Split by separator
String.replacestring, string, string -> stringReplace first occurrence
String.startsWithstring, string -> booleanCheck prefix
String.endsWithstring, string -> booleanCheck suffix
String.containsstring, string -> booleanCheck if substring exists
String.toUpperCasestring -> stringConvert to uppercase
String.toLowerCasestring -> stringConvert to lowercase
String.lengthstring -> numberCharacter count
String.slicestring, number, number -> stringExtract substring
String.padStartstring, number, string -> stringPad from the start
String.padEndstring, number, string -> stringPad from the end
String.repeatstring, number -> stringRepeat n times
String.localeComparestring, string -> numberLocale-aware string comparison
// Pipe-friendly
const cleaned = " Hello, World! "
|> String.trim
|> String.toLowerCase
|> String.replace("world", "floe")
// "hello, floe!"
// Split and process
const words = "one,two,three"
|> String.split(",")
|> Array.map((w) => String.toUpperCase(w))
// ["ONE", "TWO", "THREE"]