Retrieves one or more characters from the specified position in a string.
StringMid, OutputVar, InputVar, StartChar [, Count , L] NewStr := SubStr(String, StartPos [, Length]) ; See the SubStr() function for details.
The name of the variable in which to store the substring extracted from InputVar.
The name of the variable from whose contents the substring will be extracted. Do not enclose the name in percent signs unless you want the contents of the variable to be used as the name.
The position of the first character to be extracted, which can be an expression. Unlike StringGetPos, 1 is the first character. If StartChar is less than 1, it will be assumed to be 1. If StartChar is beyond the end of the string, OutputVar is made empty (blank).
In v184.108.40.206+, this parameter may be omitted or left blank, which is the same as specifying an integer large enough to retrieve all characters from the string.
Otherwise, specify the number of characters to extract, which can be an expression. If Count is less than or equal to zero, OutputVar will be made empty (blank). If Count exceeds the length of InputVar measured from StartChar, OutputVar will be set equal to the entirety of InputVar starting at StartChar.
The letter L can be used to extract characters that lie to the left of StartChar rather than to the right. In the following example, OutputVar will be set to Red:
InputVar = The Red Fox StringMid, OutputVar, InputVar, 7, 3, L
If the L option is present and StartChar is less than 1, OutputVar will be made blank. If StartChar is beyond the length of InputVar, only those characters within reach of Count will be extracted. For example, the below will set OutputVar to Fox:
InputVar = The Red Fox StringMid, OutputVar, InputVar, 14, 6, L
For this and all other commands, OutputVar is allowed to be the same variable as InputVar.
SubStr(), StringLeft, StringRight, StringTrimLeft, StringTrimRight, IfInString, StringGetPos, StringLen, StringLower, StringUpper, StringReplace
Source = Hello this is a test. StringMid, the_word_this, Source, 7, 4