Choose where you’d like to start

mid

Overview

The mid 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 subString or subText function to perform the same operation as the mid function.

Return Type

  • TEXT

Syntax

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

(OR)

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

where,

ParameterData typeDescription
<variable>TEXTVariable which contains the returned text.
<source_text>TEXTThe source of text on which mid 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.mid(11, 22);
 info  newText; // returns "Zoho Deluge"

Get Started Now

Execute