subString() | Zoho QEngine Help

subString()

In a nutshell
The replaceAll() function takes a string, a search string, and a replacement string as arguments. It performs a case-sensitive search and replaces all occurrences of the search string with the replacement string, returning the modified string. If the search string is not found, the original string is returned unchanged.

Overview

The subString function takes source_textstart_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).

Notes

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.

Return Type

  • TEXT

Syntax

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

(OR)

  1. <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 QEngine";
newText = sourceText.subString(11, 22);
info  newText; // returns "Zoho QEngine"