Module

Data.String.Common

Package
strings
Repository
purerl/purescript-strings

#null Source

null :: String -> Boolean

Returns true if the given string is empty.

null "" == true
null "Hi" == false

#localeCompare Source

localeCompare :: String -> String -> Ordering

Compare two strings in a locale-aware fashion. This is in contrast to the Ord instance on String which treats strings as arrays of code units:

"ä" `localeCompare` "b" == LT
"ä" `compare` "b" == GT

#replace Source

replace :: Pattern -> Replacement -> String -> String

Replaces the first occurence of the pattern with the replacement string.

replace (Pattern "<=") (Replacement "≤") "a <= b <= c" == "a ≤ b <= c"

#replaceAll Source

replaceAll :: Pattern -> Replacement -> String -> String

Replaces all occurences of the pattern with the replacement string.

replaceAll (Pattern "<=") (Replacement "≤") "a <= b <= c" == "a ≤ b ≤ c"

#split Source

split :: Pattern -> String -> Array String

Returns the substrings of the second string separated along occurences of the first string.

split (Pattern " ") "hello world" == ["hello", "world"]

#toLower Source

toLower :: String -> String

Returns the argument converted to lowercase.

toLower "hElLo" == "hello"

#toUpper Source

toUpper :: String -> String

Returns the argument converted to uppercase.

toUpper "Hello" == "HELLO"

#trim Source

trim :: String -> String

Removes whitespace from the beginning and end of a string, including whitespace characters and line terminators.

trim "   Hello  \n World\n\t    " == "Hello  \n World"

#joinWith Source

joinWith :: String -> Array String -> String

Joins the strings in the array together, inserting the first argument as separator between them.

joinWith ", " ["apple", "banana", "orange"] == "apple, banana, orange"