String Functions
Version dev
Version:
FunctionDescriptionExampleResultAliases

string ^@ search_string

Returns true if string begins with search_string

starts_with('abc','a')

true

starts_with

ascii(string)

Returns an integer that represents the Unicode code point of the first character of the string

ascii('Ω')

937

bar(x, min, max, width)

Draws a band whose width is proportional to (x - min) and equal to width characters when x = max. width defaults to 80

bar(5, 0, 20, 10)

██▌

bin(value)

Converts the value to binary representation

bin(42)

101010

to_binary

chr(code_point)

Returns a character which is corresponding the ASCII code value or Unicode code point

chr(65)

A

damerau_levenshtein(str1, str2)

Extension of Levenshtein distance to also include transposition of adjacent characters as an allowed edit operation. In other words, the minimum number of edit operations (insertions, deletions, substitutions or transpositions) required to change one string to another. Different case is considered different

damerau_levenshtein('hello', 'world')

4

format(format, parameters...)

Formats a string using fmt syntax

format('Benchmark "{}" took {} seconds', 'CSV', 42)

Benchmark "CSV" took 42 seconds

format_bytes(bytes)

Converts bytes to a human-readable presentation (e.g. 16000 -> 16KB)

format_bytes(1000 * 16)

16KB

formatReadableDecimalSize

hamming(str1, str2)

The number of positions with different characters for 2 strings of equal length. Different case is considered different

hamming('duck','luck')

1

mismatches

hex(value)

Converts the value to hexadecimal representation

hex(42)

2A

to_hex

instr(haystack, needle)

Returns location of first occurrence of needle in haystack, counting from 1. Returns 0 if no match found

instr('test test','es')

2

strpos, position

jaccard(str1, str2)

The Jaccard similarity between two strings. Different case is considered different. Returns a number between 0 and 1

jaccard('duck','luck')

0.6

jaro_similarity(str1, str2)

The Jaro similarity between two strings. Different case is considered different. Returns a number between 0 and 1

jaro_similarity('duck','duckdb')

0.8888888888888888

jaro_winkler_similarity(str1, str2)

The Jaro-Winkler similarity between two strings. Different case is considered different. Returns a number between 0 and 1

jaro_winkler_similarity('duck','duckdb')

0.9333333333333333

left(string, count)

Extract the left-most count characters

left('Hello🦆', 2)

He

left_grapheme(string, count)

Extract the left-most count grapheme clusters

left_grapheme('🤦🏼‍♂️🤦🏽‍♀️', 1)

🤦🏼‍♂️

levenshtein(str1, str2)

The minimum number of single-character edits (insertions, deletions or substitutions) required to change one string to the other. Different case is considered different

levenshtein('duck','db')

3

editdist3

lpad(string, count, character)

Pads the string with the character from the left until it has count characters

lpad('hello', 10, '>')

>>>>>hello

ltrim(string, characters)

Removes any occurrences of any of the characters from the left side of the string

ltrim('>>>>test<<', '><')

test<<

md5(value)

Returns the MD5 hash of the value as a string

md5('123')

202cb962ac59075b964b07152d234b70

md5_number(value)

Returns the MD5 hash of the value as an INT128

md5_number('123')

149263671248412135425768892945843956768

md5_number_lower(value)

Returns the MD5 hash of the value as an INT128

md5_number_lower('123')

8091599832034528150

md5_number_upper(value)

Returns the MD5 hash of the value as an INT128

md5_number_upper('123')

6559309979213966368

printf(format, parameters...)

Formats a string using printf syntax

printf('Benchmark "%s" took %d seconds', 'CSV', 42)

Benchmark "CSV" took 42 seconds

repeat(string, count)

Repeats the string count number of times

repeat('A', 5)

AAAAA

replace(string, source, target)

Replaces any occurrences of the source with target in string

replace('hello', 'l', '-')

he--o

reverse(string)

Reverses the string

reverse('hello')

olleh

right(string, count)

Extract the right-most count characters

right('Hello🦆', 3)

lo🦆

right_grapheme(string, count)

Extract the right-most count grapheme clusters

right_grapheme('🤦🏼‍♂️🤦🏽‍♀️', 1)

🤦🏽‍♀️

rpad(string, count, character)

Pads the string with the character from the right until it has count characters

rpad('hello', 10, '<')

hello<<<<<

rtrim(string, characters)

Removes any occurrences of any of the characters from the right side of the string

rtrim('>>>>test<<', '><')

>>>>test

sha256(value)

Returns the SHA256 hash of the value

sha256('hello')

2cf24dba5fb0a30e26e83b2ac5b9e29e1b161e5c1fa7425e73043362938b9824

string_split(string, separator)

Splits the string along the separator

string_split('hello-world', '-')

[hello, world]

str_split, string_to_array, split

string_split_regex(string, separator)

Splits the string along the regex

string_split_regex('hello␣world; 42', ';?␣')

[hello, world; 42]

str_split_regex, regexp_split_to_array

to_base(number, radix, min_length)

Converts a value to a string in the given base radix, optionally padding with leading zeros to the minimum length

to_base(42, 16)

2A

translate(string, from, to)

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

trim(string, characters)

Removes any occurrences of any of the characters from either side of the string

trim('>>>>test<<', '><')

test

unbin(value)

Converts a value from binary representation to a blob

unbin('0110')

\x06

from_binary

unhex(value)

Converts a value from hexadecimal representation to a blob

unhex('2A')

*

from_hex

unicode(str)

Returns the unicode codepoint of the first character of the string

unicode('ü')

252

ord

Search Shortcut cmd + k | ctrl + k