SubStr

Extracts a sub-string from within another string, such as “corn” from “unicorn”, “monk” from “monkey”, or “not” from “knotted”.

Syntax

SubStr( StringValue, SubstringStartIndex, SubstringLength );

Parameters

Parameter Name Type Description Optional? Default Value
StringValue String The string to search. No n/a
SubstringStartIndex Integer The index number of the first character to extract. No n/a
SubstringLength Integer The number of characters the sub-string should include. No n/a

Output

The sub-string extracted from the original string.

Use Case

You can use the SubStr function to create a default ID for the user based on a supplied forename and surname. The format we use will be the first two letters of their forename, followed by the entirety of their surname.

To find the first two letter of their forename, we would use the SubStr function as follows:

SubStr( ForeName, 0, 2 )

Again, we use 0 for the index because 0 is always the index of a string’s first character. If the user’s forename was “John”, the above expression would evaluate to “Jo”. Next, we use the concatenation operator to join the sub-string “Jo” to the user’s surname, which in this example is “Smith”.

UserID = SubStr( Forename, 0, 2 ) & Surname

Using this expression, the default user ID for John Smith will be “JoSmith”.