Text functions
The luego.text package contains utility functions to work with text data.
luego.text
charAt
Returns the character at the specified index i in a text t
charAtOpt
Returns the character at the specified index i in a text t, wrapped in an option
compareTo
Compares the two input texts lexicographically
compareToIgnoreCase
Compares the two input texts lexicographically, ignoring case differences
containsSubstring
Returns true if and only if the first text contains the second one
DateAsTextEn
Generate a text for the input date in the current EN locale
DateAsTextFr
Generate a text for the input date in the current FR locale
endsWith
Tests if this text ends with the specified suffix
extractWords
Split a text into a sequence of words
FormatFloatNumber
Format numeric value d to text using continental Europe format
FormatFloatNumber_US
Format numeric value d to text using US format
FormatNumber
Format numeric value d to text using format f
indexOf
Returns the index within this string s of the first occurrence of the specified substring
isEmpty
Tests whether the input text t is empty. For example: isEmpty('') returns true, isEmpty('Abc') returns false
isLower
Tells whether the input text contains only lowercase letters. For example: isLower('abc') returns true, isLower('Abc') returns false
isUpper
Tells whether the input text t contains only uppercase letters. For example: isUpper('ABC') returns true, isUpper('Abc') returns false
isValidEmail
Tells whether the input text is a valid email address
lastChar
Returns the last character of a text t
lastCharOpt
Returns the last character of a text t wrapped in an option
lastIndexOf
Returns the index within this string of the last occurrence of the specified substring
length
Returns the length of the input text t. For example: length('hello') returns 5, length('') returns 0
lower
Returns a new Text with all of the characters converted to lower case. For instance, lower('HELLO') return 'hello'
matches
Tells whether or not this text matches the given regular expression
mkString
Returns a text obtained by concatenating the list of input texts with a separator s
onlyDigits
Tests whether the input text t only contains digits. For example: onlyDigits('1234') returns true, onlyDigits('1234A') returns false
Prints out the input text t to the default output
println
Prints out the input text to the default output, followed by a newline
repeat
Returns the input Text t concatenated n times.
replace
Replaces each substring of t that matches the literal target sequence f with the specified literal replacement sequence r
replaceAll
Replaces each substring of this string that matches the given regex with the literal replacement.
reverse
Returns a new Text with characters in reverse order. For instance, reverse('hello') return 'olleh'
split
Split a text t using a separator s
startsWith
Tests if this text starts with the specified prefix
str
Converts the input into a text
substring
Returns substring of t between the specified indexes
substringOpt
Returns substring of s between the specified indexes, wrapped in an option
TimeFromDTAsText
Generate a text for the time extracted from the input dateTime
toInt
Converts the input text t to an Integer. This can fail if t does not have an Integer format.
toIntOption
Tries to parse the input text tas an Integer option. This is the safe version of toInt
toNumber
Converts the input text t to an Number. This can fail if t does not have an Number format.
toNumberOption
Tries to parse the input text t as a Number option. This is the safe version of toNumber
trim
Returns a copy of the input Text, with leading and trailing whitespace omitted
upper
Returns a new Text with all of the characters converted to upper case. For instance, upper('hello') return 'HELLO'
upperFirstLetter
Returns a new Text with the first character converted to upper case. For instance, upperFirstLetter('hello') return 'Hello'