In this article
Examples include functions to get the length of a string, remove spaces, extract substrings, and change case.
The following functions can be used to be used to manipulate or evaluate text variables:
Function | Description | Example for the string “ Forsta Studio ” |
|---|---|---|
Len(s) | Returns the length of string s | 14 |
LTrim(s) | Remove leading spaces from s | “Forsta Studio ” |
RTrim(s) | Remove trailing spaces from s | “ Forsta Studio” |
Left(s, n) | Substring of s consisting of n leftmost characters | Left (“ Forsta Studio “, 5) returns “ Fors” |
Right(s,n) | Substring of s consisting of n rightmost characters | Right (“ Forsta Studio “, 5) returns “ udio ” |
Substr(value, start, length) | Evaluates substring of text value starting from "start" position (1-based) containing "length" characters. If length points beyond the string then all characters from "start" to the end of string are returned | Substr(" Forsta Studio ", 3, 6) returns "orsta " |
Contains(s1, s2) | Boolean expression, returning True if s1 contains s2 as a substring | Contains( “ Forsta Studio “, “Stud”) returns True. |
Lower(s) | Lowercased s | “ forsta studio “ |
Upper(s) | Uppercased s | “ FORSTA STUDIO “ |
StartsWith(value, pattern) | Evaluates to true if the specified text value starts with the specified pattern. A pattern is expected to be a text constant. | StartsWith(" Forsta Studio ", " For") returns true |
EndsWith(value, pattern) | Evaluates to true if the specified text value ends with the specified pattern. A pattern is expected to be a text constant. | EndsWith(" Forsta Studio ", "dio ") returns true |
Index(searchString, pattern[, startIndex]) | Finds an index (1-based) of the specified pattern in the search string. Returns an index of the first occurrence of the pattern of 0 if it is not found. If an optional startIndex parameter is provided, then the search starts from that index in a search pattern. | Index(" Forsta Studio ", "Studio") returns 9 |
Tip
to apply string functions to non-string values (e.g. answer codes), you can use the ToText function to perform a conversion e.g. ToText(survey:filtered_QID)