Text calculations

Most of the data you collect on your forms is probably some form of text. For example: the Textbox, Choice, Rating Scale, Name, Address, Phone, Email, Website, and Calculation (Text) field types all represent text values.

Syntax

You can specify constant text values in your expressions by simply putting text inside quotes, “like this”. Also, text fields that are blank will have a value of null. Here are examples of basic text calculations you can perform for text fields like the Name field:

Example Type Results for the name John Smith
= Name.First + " " + Name.Last Concatenation “John” + " " + “Smith” = “John Smith”
= Name.First = "John" Equals “John” = “John” = true
= Name.First = null Is Blank “John” = null = false
= Name.First != null Is Not Blank “John” != null = true
= Name.First.StartsWith("J") Starts With “John”.StartsWith(“J”) = true
= Name.Last.Contains("th") Contains “Smith”.Contains(“th”) = true
= Name.FirstAndLast.ToLower Make Lowercase “John Smith”.ToLower() = “john smith”
= Name.First.Trim Remove Spaces “John”.Trim = “John”

Functions

Quick Tip

Select the function name from the list below to see an example of the function in action!

Here is a full list of supported text functions that you can call by typing a . after text field:

Function Returns Description
CompareTo(Text) Number Compares the value of this instance to a specified text value. Returns -1, 0, or 1 which means the instance precedes, same as, or follows the text in sort order, respectively.
Contains(Text) Yes/No Returns whether this instance contains the specified text.
EndsWith(Text) Yes/No Returns whether the end of this instance ends with the specified text.
IndexOf(Text) Number Returns the zero-based index of the first occurrence of the specified text in this instance.
IndexOf(Text,Number) Number Returns the zero-based index of the first occurrence of the specified text in this instance. The search will start at the specified character position.
IndexOf(Text, Number, Number) Number Returns the zero-based index of the first occurrence of the specified text in this instance. The search will start at the specified character position and examines the specified number of positions.
Insert(Number, Text) Text Returns a new text equivalent to this instance but with a text inserted at the specified character position.
LastIndexOf(Text) Number Returns the zero-based index of the last occurrence of the specified text in this instance.
LastIndexOf(Text, Number) Number Returns the zero-based index of the last occurrence of the specified text in this instance. The search will start at the specified character position.
LastIndexOf(Text, Number, Number) Number Returns the zero-based index of the last occurrence of the specified text in this instance. The search will start at the specified character position and examines the specified number of positions.
Length Number Returns the number of characters in this instance.
Split([’ ‘,’,’,’;’,’(’,’)’,’-’], “RemoveEmptyEntries”).Length Number Returns the number of words in this instance. Note: In this case, spaces, commas, semicolons, parenthesis, and dashes are considered word separators. You can adjust this for your needs.
PadLeft(Number) Text Returns a new text which is right-aligned and padded on the left with spaces for a specified total length.
PadLeft(Number, Text) Text Returns a new text which is right-aligned and padded on the left with a specified character for a specified total length.
PadRight(Number) Text Returns a new text which is left-aligned and padded on the right with spaces for a specified total length.
PadRight(Number, Text) Text Returns a new text which is left-aligned and padded on the right with a specified character for a specified total length.
Remove(Number) Text Returns a new text in which all characters of this instance after the specified number has been removed.
Remove(Number, Number) Text Returns a new text in which all characters of this instance after the specified number has been removed, for a specified length.
Replace(Text, Text) Text Returns a new text where all instances of a text have been replaced with a new text.
Split(Text) Text Returns a text array which contains substrings of this instance separated by any character in the specified character array.
Split(‘Text’)[Number] Text Returns a text array which contains substrings of this instance separated by any character in the specified character array. A specified maximum number of substring will be returned.
StartsWith(Text) Yes/No Returns whether the beginning of this instance starts with the specified text.
Substring(Number) Text Returns a substring of this instance starting at the specified character position and until the end of this instance.
Substring(Number, Number) Text Returns a substring of this instance starting at the specified character position and until the specified length.
ToLower() Text Returns a copy of this instance converted to lowercase.
ToUpper() Text Returns a copy of this instance converted to uppercase.
Trim() Text Removes all leading and trailing white-space characters from the current instance.
Trim(Text) Text Removes all leading and trailing occurrences of the specified set of characters from the current instance.
TrimEnd() Text Removes all trailing occurrences of the specified set of characters from the current instance.
TrimStart() Text Removes all leading occurrences of the specified set of characters from the current instance.