This topic describes the syntax and usage of the substring function in Zoho Creator .
The substring function extracts the characters from a string, between two specified indices ("from" and "to", not including "to" itself), and returns the new sub string.
<string>.substring(<start index>, <end index>)
mid(string , start index, end index)
// this format is supported only in the free flow scripting mode of Script builder.
The substring function syntax has the following arguments.
string - The input string
start index - Required. The index where to start the extraction. First character is at index 0
end index - Optional. The index where to stop the extraction. If omitted, it extracts the rest of the string
text="Hello world welcome to the universe";
text.substring(6,11); //returns "world"
text.substring(12); //returns "welcome to the universe"
mid("Hello world welcome to the universe",6,11); //returns "world"
mid("Hello world welcome to the universe", 12;) //returns "welcome to the universe"
This example explains a case of phone number validation. Lets say we have a Zoho Creator form to store phone numbers of users. We need to store the numbers in the format (xxx) xxx-xxxx. For example,
To achieve this, add the following function:
The function modifies any inserted phone number format to the required (xxx) xxx-xxxx format. You can call this function by adding the following script to the required form actions block:
This script returns the phone number entered in "Phone_Number" field in the required format.