Returns a segment of a string.
Sample Usage
MID("get this",5,4)
MID(A2,3,5)
Syntax
MID(string, starting_at, extract_length)
-
string
- The string to extract a segment from. -
starting_at
- The index from the left ofstring
from which to begin extracting. The first character instring
has the index 1. -
extract_length
- The length of the segment to extract.- If the end of
string
is reached beforeextract_length
characters are encountered,MID
returns the characters fromstarting_at
to the end ofstring
.
- If the end of
Notes
-
To return the contents from
starting_at
to the end ofstring
, useLEN
to calculate the length of the string that will be returned rather than simply specifying a large number forextract_length
. -
To return the contents of
string
beginning with a particular character or sub-string, useSEARCH
to locate the index of the desired point.
See Also
SUBSTITUTE
: Replaces existing text with new text in a string.
SPLIT
: Divides text around a specified character or string, and puts each fragment into a separate cell in the row.
SEARCH
: Returns the position at which a string is first found within text, ignoring case.
RIGHT
: Returns a substring from the end of a specified string.
LEFT
: Returns a substring from the beginning of a specified string.
LEN
: Returns the length of a string.