String Functions
String functions provide mechanisms for creating, transforming, and working with strings.
The examples for each function use the following notation:
- Square brackets (
[]
) indicate arrays. - Curly braces (
{}
) indicate groups. - Arrows (
==>
) separate inputs and outputs. Inputs are shown on the left side of the arrow. Outputs are shown on the right side of the arrow.
Join
The Join
function returns a string containing all input elements joined together by the specified delimiter.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1+ |
Mandatory Argument Names and Datatypes | arg : Any datatype.
|
Optional Argument Names and Datatypes | delimiter : The string to use as the delimiter. (By default, it joins the elements with no space between them.) |
Modifiers | ignore null (default: True ): If True , null values are not included in the output string. If False , null values are included as part of the output string. |
Output Datatype(s) | String |
All input data must share the same datatype.
Join
takes any of the following:
- One or more sets of supported types.
- One array.
- Two or more scalar.
- A mix of two or more scalars and sets.
- A mix of one array and one or more scalar.
Examples
join(1,2,3, delimiter="|") ==> "1|2|3"
join(1,2,null,4, ignoreNull=True) ==> "124"
join(1,2,null,4, ignoreNull=False) ==> null
join([1,2,3]) ==> "123"
join({1,2,3}, delimiter=",") ==> "1,2,3"
join(1,{2,3,4}, delimiter=',') ==> {"1,2","1,3","1,4"}
join({1,2,3},{4,5,6}, delimiter="|") ==> {"1|4","2|5","3|6"}
join({[1,2,3],[4,5,6]}, delimiter=",") ==> "[1,2,3],[4,5,6]"
Left
The Left
function returns the specified number of characters from the left of the entered string.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1 |
Mandatory Argument Names and Datatypes | arg : A string.
|
Optional Argument Names and Datatypes | num char (Default: 1 ): An integer indicating the length of the string. |
Modifiers | N/A |
Output Datatype(s) | String |
The length of the string is determined by the num char
value.
If the value of the arg
integer exceeds the length of the string, then Left
returns the complete string.
Examples
left("ABCDEFG",num_char=3) ==> "ABC"
left(["ABCDEFG","1234567","!@#$%^&"],num_char=3) ==> ["ABC","123","!@#"]
left({"ABCDEFG","1234567","!@#$%^&"},num_char=3) ==> {"ABC","123","!@#"}
left({"ABCDEFG","1234567","!@#$%^&"},num_char={1,2,3}) ==> {"A","12","!@#"}
left({["ABCDEFG","1234567","!@#$%^&"],["ABCDEFG","1234567","!@#$%^&"],["ABCDEFG","1234567","!@#$%^&"]},num_char=3) ==> {["ABC","123","!@#"],["ABC","123","!@#"],["ABC","123","!@#"]}
Length
The Length
function returns the total number of characters in the specified string.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1 |
Mandatory Argument Names and Datatypes | arg : A string.
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | Integer |
Examples
length("ABCDEFG") ==> 7
length(["ABCDE","1234567","!@#$%^"]) ==> [5,7,6]
length({"ABCDE","1234567","!@#$%^"}) ==> {5,7,6}
length({["ABCDE","1234567","!@#$%^"],["ABCDE","1234567","!@#$%^"],["ABCDE","1234567","!@#$%^"]}) ==> {[5,7,6],[5,7,6],[5,7,6]}
Lower
The Lower
function returns a string where all the characters from the input string are converted to lowercase.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1 |
Mandatory Argument Names and Datatypes | arg : A string.
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | String |
Examples
lower("ABCDEFG") ==> "abcdefg"
lower(["ABC","DEF","GHI"]) ==> ["abc","def","ghi"]
lower({"ABC","DEF","GHI"}) ==> {"abc","def","ghi"}
lower({["ABC","DEF","GHI"],["ABC","DEF","GHI"],["ABC","DEF","GHI"]}) ==> {["abc","def","ghi"],["abc","def","ghi"],["abc","def","ghi"]}
Replace All
The Replace All
function returns a string where all occurrences of a given regular expression (regex) in the input string are replaced with the specified replacement string.
Usage Information
Category | Details |
---|---|
Number of Arguments | 3 |
Mandatory Argument Names and Datatypes |
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | String |
Examples
replaceAll("I love pickles!", replace="pickles", with="Cogynt") ==> "I love Cogynt!"
replaceAll("I love pickles!", replace=" ", with="-") ==> "I-love-pickles!"
replaceAll("I love pickles!", replace="food", with="salads") ==> "I love pickles!"
replaceAll(["I love pickles!","I love dogs!","I love cats!"],replace=" ", with="-") ==> ["I-love-pickles!","I-love-dogs","I-love-cats"]
replaceAll({"I love pickles!","I love dogs!","I love cats!"},replace=" ", with="-") ==> {"I-love-pickles!","I-love-dogs","I-love-cats"}
replaceAll({"I love pickles!","I love dogs!","I love cats!"},replace={" ","!","don't like"}, with={"-","...","like"}) ==> {"I-love-pickles!","I love dogs...","I love cats!"}
Replace First
The Replace First
function returns a string where the first occurrence of a given regular expression (regex) in the input string is replaced with the specified replacement string.
Usage Information
Category | Details |
---|---|
Number of Arguments | 3 |
Mandatory Argument Names and Datatypes |
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | String |
Examples
replaceFirst("I love pickles!", replace="pickles", with="Cogynt") ==> "I love Cogynt!"
replaceFirst("I love pickles!", replace=" ", with="-") ==> "I-love pickles!"
replaceFirst("I love pickles!", replace="food", with="salads") ==> "I love pickles!"
replaceFirst(["I love pickles!","I love dogs!","I love cats!"],replace=" ", with="-") ==> ["I-love pickles!","I-love dogs","I-love cats"]
replaceFirst({"I love pickles!","I love dogs!","I love cats!"},replace=" ", with="-") ==> {"I-love pickles!","I-love dogs","I-love cats"}
replaceFirst({"I love pickles!","I love dogs!","I love cats!"},replace={" ","!","don't like"}, with={"-","...","like"}) ==> {"I-love pickles!","I love dogs...","I love cats!"}
Right
The Right
function returns the specified number of characters from the right of the entered string.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1 |
Mandatory Argument Names and Datatypes | arg : A string.
|
Optional Argument Names and Datatypes | num char (Default: 1 ): An integer indicating the number of characters to return. |
Modifiers | N/A |
Output Datatype(s) | String |
If the value of the num char
integer exceeds the length of the string, then Right
returns the complete string.
Examples
right("ABCDEFG", num_char=3) ==> "EFG"
right(["ABCDEFG","1234567","!@#$%^&"],num_char=3) ==> ["EFG","567","%^&"]
right({"ABCDEFG","1234567","!@#$%^&"},num_char=3) ==> {"EFG","567","%^&"}
right({"ABCDEFG","1234567","!@#$%^&"},num_char={1,2,3}) ==> {"G","67","%^&"}
right({["ABCDEFG","1234567","!@#$%^&"],["ABCDEFG","1234567","!@#$%^&"],["ABCDEFG","1234567","!@#$%^&"]},num_char=3) ==> {["EFG","567","%^&"],["EFG","567","%^&"],["EFG","567","%^&"]}
Split
The Split
function splits the input string by the specified delimiter, and returns an array of characters or words from the input string.
Usage Information
Category | Details |
---|---|
Number of Arguments | 2 |
Mandatory Argument Names and Datatypes | arg : The input string.
|
Optional Argument Names and Datatypes | by (Default: ""): A string representing the delimiter by which the input string will be split. If no argument is specified, the input string will be split into all of its individual characters. |
Modifiers | N/A |
Output Datatype(s) | Array of strings |
Examples
split("I am a bird.") ==> ['I','','a','m','','a','','b','i','r','d','.']
split("I am a bird.", by=" ") ==> ['I','am','a','bird.']
split("I am a bird.\nI can fly.", by="\n") ==> ["I am a bird.","I can fly."]
split("I am a bird.\rI can fly.", by="\r") ==> ["I am a bird.","I can fly."]
split("I am a bird.", by=",") ==> ["I am a bird."]
split("") ==> [""]
split(null) => null
split("I am a bird.", by=null) ==> null
split(|"I am a bird.", "I can fly.", "I have wings."|, by=" ") ==> |["I","am","a","bird."],["I","can","fly."],["I","have","wings."]|
split(|"I am a bird.", "I can fly.", "I have wings."|, by=|" ",null,"."|) ==> |["I","am","a","bird."],null,["I have wings"]|
Special escapable characters, such as \n
for new line, \r
for return, and \t
for tab, can be used as a delimiter in the by
argument.
Sub String
The Sub String
function returns a substring from an input string, beginning with the submitted starting index and continuing to the specified length.
Usage Information
Category | Details |
---|---|
Number of Arguments | 2 |
Mandatory Argument Names and Datatypes |
|
Optional Argument Names and Datatypes | length (Default: The end of the string.): An integer specifying the length of the substring to return. If null, the default value is used. |
Modifiers | N/A |
Output Datatype(s) | String |
Examples
substring("ABCDEFG",start_index=2,length=3) ==> "CDE"
substring(["ABCDEFG","1234567","!@#$%^&"],start_index=2,length=3) ==> ["CDE","345","#$%"]
substring({"ABCDEFG","1234567","!@#$%^&"},start_index=2) ==> {"CDEFG","34567","#$%^&"}
substring({"ABCDEFG","1234567","!@#$%^&"},start_index={2,3,4},length={1,2,3}) ==> {"CDEFG","4567","%^&"}
Trim
The Trim
function removes leading and trailing spaces from the submitted string and returns the resulting string.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1 |
Mandatory Argument Names and Datatypes | arg : The string to trim.
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | String |
Examples
trim(" X\n Y \nZ \t") ==> "X\n Y \nZ \t"
trim([" X\n Y \nZ \t"," space at beginning","space at the end. "]) ==> ["", "space at beginning", "space at the end."]
trim({" X\n Y \nZ \t"," space at beginning","space at the end. "}) ==> {"", "space at beginning", "space at the end."}
trim({[],[],[]}) ==> {[],[],[]}
Upper
The Upper
function returns a string where all characters from the input string are converted to uppercase.
Usage Information
Category | Details |
---|---|
Number of Arguments | 1 |
Mandatory Argument Names and Datatypes | arg : The string to convert.
|
Optional Argument Names and Datatypes | N/A |
Modifiers | N/A |
Output Datatype(s) | String |
Examples
upper("abcdefg") ==> "ABCDEFG"
upper(["abc","def","ghi"]) ==> ["ABC","DEF","GHI"]
upper({"abc","def","ghi"}) ==> {"ABC","DEF","GHI"}
upper({["abc","def","ghi"],["abc","def","ghi"],["abc","def","ghi"]}) ==> {["ABC","DEF","GHI"],["ABC","DEF","GHI"],["ABC","DEF","GHI"]}