The following functions are available.

Function Name Arguments Description Example
Len Len(s) Returns the length of a string (in bytes). s returns the number of elements if s is an array or an object. Len(“abcdefghijk”) -> 11
Contains Contains(s, substr) The return value is a bool depending on if the substring is included in s Contains(“abc”, “a”) -> true
RuneCount RuneCount(s) Returns the number of characters in the s string. RuneCount(“abc012漢字”) -> 8
HasPrefix HasPrefix(s, prefix) Depending on if s begins with a prefix, the function returns a bool HasPrefix(“https://www.asteria.com/”, “https://”) -> true
HasSuffix HasSuffix(s, suffix) If s ends with a suffix the functions returns with a bool
Index Index(s, substr) Returns the position of the first occurrence of the substring in s. If it doesn’t appear, it returns -1 Index(“abcdefg”, “cdef”) -> 3
Join Join(a, sep) Make the elements of the array a into one string with a separator in-between. Join([“abc”,“def”], “-”) -> “abc-def”
LastIndex LastIndex(s, substr) Returns the position of the last occurrence of the substring in s. If it doesn’t find anything, it returns -1.
Repeat Repeat(s, count) Returns a string of s repeated count amount of times Repeat(“abc”, 3) -> “abcabcabc”
Replace Replace(s, old, new[, n]) Replace the old string in s with the new string up to the nth time. If n is less than 0 the function will apply to all occurrences (default is -1).
Split Split(s, sep[, n]) Return an array of s separated by a separator sep to a maximum of n elements, if n is less than 0, all of them will be affected (default is -1) Split(“a,b,c”, “,”) -> [“a”, “b”, “c”]
ToLower ToLower(s) Convert s to lowercase
ToUpper ToUpper(s) Convert s to uppercase
Trim Trim(s[, cutset]) Returns a string minus the letter at the beginning of the s and the characters in the last cutset, where cutset is a space character by default Trim(” abc “) -> “abc”
TrimLeft TrimLeft(s[, cutset]) Returns a string excluding the characters in the s minus the cutset, where cutset is a space character by default
TrimRight TrimRight(s[, cutset]) Returns a string except for the characters in the last cutset of s. Cutset defaults to a space character
TrimPrefix TrimPrefix(s, prefix) If s begins with a prefix, the function returns the string without it. If it doesn’t start, it returns s as it is. TrimPrefix(“https://www.asteria.com”, “https://”) -> “www.asteria.com”
TrimSuffix TrimSuffix(s, suffix) If s is terminated by a suffix, return a string with the stripped string. If the s is not terminated, it returns the s as it is.
JSONPath JSONPath(path, s) Returns the value as a string, specified by path from s. JSONPath(“$.store.book[*].author”, cv.Payload)
Sprintf Sprintf(format, s) Formats a formatted string and returns a string. Formatting can be specified as % followed by a conversion specifier and options flags, width, and precision. Sprintf(“Number of messages: %d”, ToInt(cv.Payload))
IFS IFS (condition 1, value 1[, condition 2, value 2, …]) Evaluates the conditions in the order of the parameters from the 1st parameter and returns the respective value that matches. If you specify true for the condition, it will always match, therefore if you specify true for the last condition-value pair, you can specify a condition matching everything else. IFS (ToFloat(cv.Payload) >= 10, “more than 10”, true, “Less than 10”)

Need more help with this?
Join our slack community for help

Was this helpful?

Yes No
You indicated this topic was not helpful to you ...
Could you please leave a comment telling us why? Thank you!
Thanks for your feedback.