Choose where you’d like to start

subString

Overview

The subString function takes source_text, start_index, and end_index as arguments. It returns a piece of text containing characters between the specified indices (including the start_index and excluding the end_index).

Note:

  • Index starts from 0
  • The start_index and/or end_index should not exceed the length of the source_text. If it exceeds, an error will be encountered during execution.
  • The end_index must be greater than or equal to the start_index, failing which an error will be encountered during runtime.
  • If start_index and end_index are the same, then the function will return an empty text.
  • You can use the subText or mid function to perform the same operation as the subString function.

Return Type

  • TEXT

Syntax

<variable> = <source_text>.subString(<start_index>, [<end_index>]);

(OR)

<variable> = subString(<source_text>, <start_index>, [<end_index>]);

where,

ParameterData typeDescription
<variable>TEXTVariable which contains the returned text.
<source_text>TEXTThe source of text on which subString function is effected.
<start_index>NUMBER

The index starting from which the characters in the source text will be returned.

<end_index>

 (optional)

NUMBER

The index until which the characters in the source text will be returned. If omitted, the rest of the text (from the start index) will be returned.

If a negative value is specified, this param will be ignored and rest of the text (from the start index) will be returned.

Examples

sourceText = "Welcome to Zoho Deluge"; 
newText = sourceText.subString(11, 22); 
info newText; // returns Zoho Deluge 

Email_Data = "Email: jack@zylker.com"; 
Email = Email_Data.subString(7); 
info Email;   // returns jack@zylker.com 

Date_Time_Data = "15-Aug-1947 12:00:00"; 
Date = Date_Time_Data.subString(0,11); 
info Date;    // returns 15-Aug-1947

Get Started Now

Execute