Wraps the functions of Javascript's String object.
A String represents a sequence of characters.
For details of the underlying implementation, see String Reference at MDN.
charAt :: Int -> String -> Maybe CharReturns the character at the given index, if the index is within bounds.
fromChar :: Char -> StringReturns a string of length 1 containing the given character.
singleton :: Char -> StringReturns a string of length 1 containing the given character.
Same as fromChar.
charCodeAt :: Int -> String -> Maybe IntReturns the numeric Unicode value of the character at the given index, if the index is within bounds.
toChar :: String -> Maybe Charnull :: String -> BooleanReturns true if the given string is empty.
uncons :: String -> Maybe { head :: Char, tail :: String }Returns the first character and the rest of the string, if the string is not empty.
takeWhile :: (Char -> Boolean) -> String -> StringReturns the longest prefix (possibly empty) of characters that satisfy the predicate:
dropWhile :: (Char -> Boolean) -> String -> StringReturns the suffix remaining after takeWhile.
stripPrefix :: String -> String -> Maybe StringIf the string starts with the given prefix, return the portion of the string left after removing it, as a Just value. Otherwise, return Nothing.
stripPrefix "http:" "http://purescript.org" == Just "//purescript.org"stripPrefix "http:" "https://purescript.org" == Nothing
stripSuffix :: String -> String -> Maybe StringIf the string ends with the given suffix, return the portion of the string left after removing it, as a Just value. Otherwise, return Nothing.
stripSuffix ".exe" "psc.exe" == Just "psc"stripSuffix ".exe" "psc" == Nothing
fromCharArray :: Array Char -> StringConverts an array of characters into a string.
contains :: String -> String -> BooleanChecks whether the first string exists in the second string.
indexOf :: String -> String -> Maybe IntReturns the index of the first occurrence of the first string in the
second string. Returns Nothing if there is no match.
indexOf' :: String -> Int -> String -> Maybe IntReturns the index of the first occurrence of the first string in the
second string, starting at the given index. Returns Nothing if there is
no match.
lastIndexOf :: String -> String -> Maybe IntReturns the index of the last occurrence of the first string in the
second string. Returns Nothing if there is no match.
lastIndexOf' :: String -> Int -> String -> Maybe IntReturns the index of the last occurrence of the first string in the
second string, starting at the given index. Returns Nothing if there is
no match.
length :: String -> IntReturns the number of characters the string is composed of.
localeCompare :: String -> String -> OrderingLocale-aware sort order comparison.
replace :: String -> String -> String -> StringReplaces the first occurence of the first argument with the second argument.
take :: Int -> String -> StringReturns the first n characters of the string.
drop :: Int -> String -> StringReturns the string without the first n characters.
count :: (Char -> Boolean) -> String -> IntReturns the number of contiguous characters at the beginning of the string for which the predicate holds.
split :: String -> String -> Array StringReturns the substrings of the second string separated along occurences of the first string.
split " " "hello world" == ["hello", "world"]
toCharArray :: String -> Array CharConverts the string into an array of characters.
toLower :: String -> StringReturns the argument converted to lowercase.
toUpper :: String -> StringReturns the argument converted to uppercase.
trim :: String -> StringRemoves whitespace from the beginning and end of a string, including whitespace characters and line terminators.
joinWith :: String -> Array String -> StringJoins the strings in the array together, inserting the first argument as separator between them.