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) Return by Bool to see if the substring is included in the s Contains(“abc”, “a”) -> true
RuneCount RuneCount(s) Returns the number of characters in the s string. RuneCount(“aÀ漢:あはは:b”) -> 5
HasPrefix HasPrefix(s, prefix) s begins with a prefix or returns with a Bool HasPrefix(“https://www.asteria.com/”, “https://”) -> true
HasSuffix HasSuffix(s, suffix) s ends with a suffix or returns with a Bool
Index Index(s, substr) Returns the position of the first occurrence of the substring in s. If not, it is -1. If not, it returns -1 Index(“abcdefg”, “cdef”) -> 3
Join Join(a, sep) Make the elements of the array “a” into one string with a sep in between. Join([“abc”,“def”], “-”) -> “abc-def”
LastIndex LastIndex(s, substr) Returns the position of the last occurrence of the substring in s. If not, it is -1. If not, it returns -1
Repeat Repeat(s, count) Returns a string of s repeated count 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. n is less than 0 for all (default is -1).
Split Split(s, sep[, n]) Return an array of s separated by sep to a maximum of n elements, if n is less than 0, all of them (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-head 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, it 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 the 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.

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.