String functions
This page goes over the string functions in Upsolver.
Decode a base 64 string into a string.
value | result |
"SGVsbG8gV29ybGQ=" | "Hello World" |
"###" | null |
Returns a substring of the input, using the offsets in bytes of the UTF-8 encoded byte representation. Partial characters and invalid UTF-8 code points are removed from the result.
- value - Value to substring
- Start Index - The inclusive start index in bytes
- End Index - The exclusive end index in bytes
value | Start Index | End Index | result |
"Hello World" | 0 | 10 | "Hello Worl" |
"Hello World" | 1 | 10 | "ello Worl" |
"⻤Hello Wor⻤" | 1 | 10 | "Hello W" |
"⻤Hello Wor⻤" | 0 | 10 | "⻤Hello W" |
"Hello" | 0 | 10 | "Hello" |
Joins any number of arrays by index using a MessageFormat pattern.
- Format String - The format string where
{n}
prints the nth input.- For example, the pattern
'{0}.{0}.{1}'
on the inputs'a'
and'b'
will result in the string'a.a.b'
Hashes the input using MD5.
input | result |
"hello world" | "5eb63bbbe01eeed093cb22bb8f5acdc3" |
This function returns the given string split by the provided delimiter.
PRESTO_SPLIT(STRING,DELIMITER)
STRING
A sequence of characters. DELIMITER
A sequence of one or more characters for specifying the boundary between
separate, independent regions in plain text.The given string split by the provided delimiter.
String | Delimiter | Result |
'a""b' | '"' | "a", , "b" |
'-a-bc-d-' | '-' | , "a", "bc", "d", |
"~~a~~b~~" | "~~" | , "a", "b", |
'Abra&Cadabra' | '&' | "Abra", "Cadabra" |
Matches the regular expression on the input string. Returns the escape groups if any exists or the original string if none exists.
- Pattern - Regular Expression Pattern
input | Pattern | result |
"abcijefjabc" | "abc" | "abc" , "abc" |
Matches the regular expression on the input string and returns the index of the first match.
- value
- startPosition
- Pattern - Pattern to search for
Matches the regular expression on the input string. Returns record with field names and group names.
- Pattern - Regular Expression Pattern
- All Matches - Return all the matches of the pattern, and not only the first one
- Filter Empty - Filter out empty matches
input | Pattern | All Matches | Filter Empty | result |
"https://www.domain.com/ page.html" | "^(?:(?<scheme>.*?):\/)?\/? (?<domain>[^:\/\s]+) (?::(?<port>\d*))?(?:(\/\w+)*\/) (?<page>[\w\-\.]+[^#?\s]+) (?:.*)?$" | false | false | {"scheme": "https", "domain": "www.domain.com", "page": "page.html"} |
"http://www.domain.com: 8080/page.html" | "^(?:(?<scheme>.*?):\/)?\/? (?<domain>[^:\/\s]+) (?::(?<port>\d*))?(?:(\/\w+)*\/) (?<page>[\w\-\.]+[^#?\s]+) (?:.*)?$" | false | false | {"scheme": "http", "domain": "www.domain.com", "port": "8080", "page": "page.html"} |
"123" | "^(?<digits>\d*)$" | false | false | {"digits": "123"} |
"foo" | "^(?<digits>\d*)$" | false | false | null |
"" | "^(?<digits>\d*)$" | false | false | {"digits": ""} |
"" | "^(?<digits>\d*)$" | false | true | null |
"www.upsolver.com" | "\bwww.(?<domain>[^\.]*).com\b" | true | false | {"domain": "upsolver"} |
"www.a.com www.b.com" | "\bwww.(?<domain>[^\.]*).com\b" | true | false | {"domain": "a"} , {"domain": "b"} |
"www.a.com www.b.com" | "\bwww.(?<domain>[^\.]*).com\b" | false | false | {"domain": "a"} |
Replace substrings within a string.
- Pattern - Pattern to replace (regex)
- Replacement - Replacement string
value | Pattern | Replacement | result |
"Hello World" | "Hello" | null | " World" |
"Hello World" | "Hello" | "foo" | "foo World" |
"World" | "Hello" | "foo" | "World" |
Hashes the input using SHA-1.
input | result |
"hello world" | "2aae6c35c94fcfb415dbe95f408b9ce91ee846ed" |
Hashes the input using SHA-256.
input | result |
"Hello SHA" | "4ea3b17f15346417f4c9b2ff94a1bfe82de99fdb0bbd30dc4dca031ab920d5e4" |
Returns an error message indicating that SPLIT has been deprecated.
Returns the given string split by the provided delimiter.
SPLIT_DELIMITER_FIRST(DELIMITER, STRING)
DELIMITER
A sequence of one or more characters for specifying the boundary between
separate, independent regions in plain text. STRING
A sequence of characters. The given string split by the provided delimiter.
Delimiter | Input String | Result |
"," | "a,b,c,d" | "a" , "b" , "c" , "d" |
"," | "a" , "b" | "a" , "b" |
"," | ",a,b," | "a" , "b" |
"~~" | "~~a~~b~~" | "a" , "b" |
Returns the given string split by the provided delimiter.
- Field Names
- Delimiter
- Filter Empty Values
value | Field Names | Delimiter | Filter Empty Values | result |
"1,2,3,4" | "a,b,c" | "," | false | {"a": "1", "b": "2", "c": "3"} |
"1,2" | "a,b,c" | "," | false | {"a": "1", "b": "2", "c": ""} |
"1,,3" | "a,b,c" | "," | true | {"a": "1", "c": "3"} |
Format any number of inputs into a string using the given format.
- Format String - The format string where
{n}
prints the nth input.- For example, the pattern
'{0}.{0}.{1}
' on the inputs'a'
and'b'
will result in the string'a.a.b'
inputs | Format String | result |
"a" , "b" , "c" | "{0} {1} {2}" | "a b c" |
1.23 | "{0}" | "1.23" |
0.5 | "{0,number,percent}" | "50%" |
1.23 | "{0,number,#.###}" | "1.235" |
1.2 | "{0,number,#.###}" | "1.2" |
1.23 | "{0,number,0.000}" | "1.235" |
1.2 | "{0,number,0.000}" | "1.200" |
1.23E8 | "{0,number,###,###.###}" | "123,456,789.012" |
1.23E8 | "{0,number,000,000.000}" | "123,456,789.012" |
Gets the length of the string.
input | result |
"" | 0 |
"Hello" | 5 |
For each line remove prefix of control or whitespace characters followed by the given margin char.
- Margin Char
input | Margin Char | result |
"Hello
∣ World" | "∣" | "Hello
World" |
Remove the given prefix string from the beginning of the string.
- Prefix
input | Prefix | result |
"((foo))" | "(" | "(foo))" |
"foo" | "(" | "foo" |
Remove the given suffix string from the end of the string.
- Suffix
input | Suffix | result |
"((foo))" | ")" | "((foo)" |
"foo" | ")" | "foo" |
Returns a string that is a substring of the given string.
- value
- startPosition
- endPosition
value | startPosition | endPosition | result |
"Hello World" | 0 | 5 | "Hello" |
"Hello" | 0 | -1 | "Hello" |
"Hello" | 1 | 3 | "el" |
"Hello" | 6 | -1 | "" |
"Hello" | -3 | -2 | "ll" |
Get the top private domain from a domain name.
value | result |
"www.example.com" | "example.com" |
"www.example.co.uk" | "example.co.uk" |
"www.example.uk.com" | "example.uk.com" |
Converts the string to lowercase letters.
input | result |
"HELLO world" | "hello world" |
Converts the string to uppercase letters.
input | result |
"HELLO world" | "HELLO WORLD" |
Translates the given value using a given dictionary.
- Dictionary
- Keep Values Without Translation - Whether to keep values that have that are not mapped to a value in the feature
- Empty As Null - If set, empty values will be treated as null
input | Dictionary | Keep Values Without Translation | Empty As Null | result |
"a" | "a,Antman
b,Batman
d," | false | false | "Antman" |
"b" | "a,Antman
b,Batman
d," | false | false | "Batman" |
"c" | "a,Antman
b,Batman
d," | false | false | null |
"c" | "a,Antman
b,Batman
d," | true | false | "c" |
"d" | "a,Antman
b,Batman
d," | true | true | null |
"d" | "a,Antman
b,Batman
d," | true | false | "" |
1234 | "1234.0,good" | false | false | "good" |
1234 | "1234.0,good" | false | false | "good" |
0 | "0.0,good" | false | false | "good" |
0 | "-0.0,good" | false | false | "good" |
0 | "-0.0,good" | false | false | "good" |
123456000000000000 | "1.23456e17,good" | false | false | "good" |
6 | "6.000000000000001,good" | false | false | null |
Returns the given string without leading or trailing whitespaces.
input | result |
"foo" | "foo" |
" foo" | "foo" |
"foo " | "foo" |
" foo " | "foo" |
Returns the given string without leading or trailing characters.
- Characters
input | Characters | result |
"-==--Hello World---=---" | "-=" | "Hello World" |
"" | "-" | "" |
"-----------" | "-" | "" |
"x-----------" | "-" | "x" |
"-----------x" | "-" | "x" |
"------x-----" | "-" | "x" |
"x-----------x" | "-" | "x-----------x" |
Decode url encoded text.
input | result |
"The+quick+brown+fox" | "The quick brown fox" |
"Comment+%235" | "Comment #5" |
Encode text to url encoded format.
input | result |
"The quick brown fox" | "The+quick+brown+fox" |
"Comment #5" | "Comment+%235" |
Parses the URI/URL into its component parts.
value | result |
"https://www.domain.com/page.html" | {"scheme": "https", "authority": "www.domain.com", "host": "www.domain.com", "path": "/page.html"} |
"https://user:[email protected]:80/page.html?query#fragment" | {"scheme": "https", "user_info": "user:pass", "authority": "user:[email protected]:80", "host": "www.domain.com", "port": 80, "path": "/page.html", "query": "query", "fragment": "fragment"} |
"user:[email protected]/page.html?query" | {"user_info": "user:pass", "authority": "user:[email protected]", "host": "www.domain.com", "path": "/page.html", "query": "query"} |
"www.domain.com/page.html#fragment" | {"authority": "www.domain.com", "host": "www.domain.com", "path": "/page.html", "fragment": "fragment"} |
"/www.domain.com" | {"path": "/www.domain.com"} |
Returns UUID.
- hash - Value for extra randomness
Last modified 1yr ago