Expand description
Unicode expressions
Functions
- Returns number of characters in the string. character_length(‘josé’) = 4 The implementation counts UTF-8 code points to count the number of characters
- Returns first n characters in the string, or when n is negative, returns all but last |n| characters. left(‘abcde’, 2) = ‘ab’ The implementation uses UTF-8 code points as characters
- Extends the string to length ‘length’ by prepending the characters fill (a space by default). If the string is already longer than length then it is truncated (on the right). lpad(‘hi’, 5, ‘xy’) = ‘xyxhi’
- Reverses the order of the characters in the string. reverse(‘abcde’) = ‘edcba’ The implementation uses UTF-8 code points as characters
- Returns last n characters in the string, or when n is negative, returns all but first |n| characters. right(‘abcde’, 2) = ‘de’ The implementation uses UTF-8 code points as characters
- Extends the string to length ‘length’ by appending the characters fill (a space by default). If the string is already longer than length then it is truncated. rpad(‘hi’, 5, ‘xy’) = ‘hixyx’
- Returns starting index of specified substring within string, or zero if it’s not present. (Same as position(substring in string), but note the reversed argument order.) strpos(‘high’, ‘ig’) = 2 The implementation uses UTF-8 code points as characters
- Extracts the substring of string starting at the start’th character, and extending for count characters if that is specified. (Same as substring(string from start for count).) substr(‘alphabet’, 3) = ‘phabet’ substr(‘alphabet’, 3, 2) = ‘ph’ The implementation uses UTF-8 code points as characters
- Replaces each character in string that matches a character in the from set with the corresponding character in the to set. If from is longer than to, occurrences of the extra characters in from are deleted. translate(‘12345’, ‘143’, ‘ax’) = ‘a2x5’