EN
PréludeChargé par défaut — aucun import nécessaire.

Opérations String étendues

Synopsis
clampNat : Int -> Nat
takeCs : Int -> List Char -> List Char
dropCs : Int -> List Char -> List Char
slice : Int -> Int -> String -> String

Les points de code dans l'intervalle semi-ouvert [start, end), avec start et end ramenés aux bornes de la chaîne : String.slice 1 4 "abcdef" = "bcd", String.slice (0 - 5) 2 "abc" = "ab".

substring : Int -> Int -> String -> String

len points de code à partir de start : String.substring 2 3 "abcdef" = "cde". Égal à slice start (start + len).

contains : String -> String -> Bool

La chaîne contient-elle needle comme sous-chaîne ?

indexOf : String -> String -> Maybe Int

L'indice (en points de code) de la première occurrence de needle, ou Nothing. Le motif vide est trouvé à l'indice 0.

repeat : Int -> String -> String

n copies de la chaîne concaténées (vide si n ≤ 0) : String.repeat 3 "ab" = "ababab".

padLeft : Int -> Char -> String -> String

Complète à GAUCHE avec fill jusqu'à au moins width points de code (renvoie la chaîne inchangée si elle est déjà aussi large) : String.padLeft 5 '0' "42" = "00042".

padRight : Int -> Char -> String -> String

Complète à DROITE avec fill jusqu'à au moins width points de code.

replace : String -> String -> String -> String

Remplace chaque occurrence non chevauchante de old par new. Un old vide laisse la chaîne inchangée. String.replace "ab" "X" "abcab" = "XcX".

splitOn : String -> String -> List String

Découpe selon un séparateur (éventuellement multi-caractère), en gardant les fragments vides : String.splitOn ", " "a, b, c" = ["a", "b", "c"], String.splitOn ":" "a::b" = ["a", "", "b"]. Un séparateur vide rend la chaîne entière comme unique fragment.