Data.String.CodePoints
- Package
- purescript-strings
- Repository
- purescript/purescript-strings
These functions allow PureScript strings to be treated as if they were sequences of Unicode code points instead of their true underlying implementation (sequences of UTF-16 code units). For nearly all uses of strings, these functions should be preferred over the ones in Data.String.
#codePointToInt Source
codePointToInt :: CodePoint -> Int
#codePointAt Source
codePointAt :: Int -> String -> Maybe CodePoint
Returns the first code point of the string after dropping the given number of code points from the beginning, if there is such a code point. Operates in constant space and in time linear to the given index.
#fromCodePointArray Source
fromCodePointArray :: Array CodePoint -> String
Creates a string from an array of code points. Operates in space and time linear to the length of the array.
#lastIndexOf Source
lastIndexOf :: Pattern -> String -> Maybe Int
Returns the number of code points preceding the last match of the given pattern in the string. Returns Nothing when no matches are found.
#toCodePointArray Source
toCodePointArray :: String -> Array CodePoint
Creates an array of code points from a string. Operates in space and time linear to the length of the string.
Re-exports from Data.String
#Replacement Source
newtype Replacement
A newtype used in cases to specify a replacement for a pattern.
Constructors
Instances
#trim Source
trim :: String -> String
Removes whitespace from the beginning and end of a string, including whitespace characters and line terminators.
#toCharArray Source
toCharArray :: String -> Array Char
Converts the string into an array of characters.
#stripSuffix Source
stripSuffix :: Pattern -> String -> Maybe String
If 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 (Pattern ".exe") "psc.exe" == Just "psc"
stripSuffix (Pattern ".exe") "psc" == Nothing
#stripPrefix Source
stripPrefix :: Pattern -> String -> Maybe String
If 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 (Pattern "http:") "http://purescript.org" == Just "//purescript.org"
stripPrefix (Pattern "http:") "https://purescript.org" == Nothing
#replaceAll Source
replaceAll :: Pattern -> Replacement -> String -> String
Replaces all occurences of the first argument with the second argument.
#replace Source
replace :: Pattern -> Replacement -> String -> String
Replaces the first occurence of the first argument with the second argument.
#localeCompare Source
localeCompare :: String -> String -> Ordering
Locale-aware sort order comparison.
#fromCharArray Source
fromCharArray :: Array Char -> String
Converts an array of characters into a string.