MID (Text, StartIndex, Length?) MID (Text; StartIndex; Length?)

Text

Text Text

The text string containing a part to extract.

StartIndex

Number Number

The position in the text string marking the start of the part to be returned. The first character has position 1.

Length

Number Number (optional)

The number of characters to include. If omitted, the rest of the text string is returned, starting at the given start position.

Returns

Text Text

The sought text from the given text string.

Returns text from any part of a text string, effectively returning a substring. MID ("abcd", 2) MID ("abcd"; 2) returns "bcd", the characters of "abcd" starting at position 2. MID ("abcd", 2, 2) MID ("abcd"; 2; 2) returns "bc", two characters from "abcd" starting at position 2.

Consider using the CHARAT function instead if you need to extract a single character.

Examples

MID ("abcd", 1, 1)
MID ("abcd"; 1; 1)

Returns "a", the first character of "abcd".

MID ("abcd", 1, 2)
MID ("abcd"; 1; 2)

Returns "ab", the first two characters of "abcd".

MID ("abcd", 2, 2)
MID ("abcd"; 2; 2)

Returns "bc", two characters of "abcd" starting with "b".

MID ("abcd", 2)
MID ("abcd"; 2)

Returns "bcd", the characters of "abcd" starting at position 2.

MID ("abcd", 2, 2)
MID ("abcd"; 2; 2)

Returns "bc", two characters from "abcd" starting at position 2.

fxEngine Shell Want this in your own terminal? A standalone version is coming. Get notified.
Loading fxEngine Shell