mid()

Read(2269) Label: string, substring,

Description:

Get a substring of a string.

Syntax:

mid(s,n{,l})

Note:

The function gets a substring of the length of l from string s starting from the nth character.

Parameter:

s

The source string

n

The starting position of the substring; if n<0, count backwards from the last character of source string s, fill in the extra positions with spaces and make the abs(n)th-to-last character the starting position

l

The length of substring; by default, the length will be counted from the starting character to the end of the source string

Return value:

String

Example:

mid("abcde",1)

abcde.

mid("abcde",1,2)

ab.

mid("abcde",3)

cde.

mid("abcde",-3,2)

cd; use the third-to-last character as the starting position to 2 get a substring whose length is 2.

mid("abcde",-8,5)

ab; treat the 8th-to-last character of string _ _ _abcde as the starting position, where characters _ _ _ before the source string are complement spaces, get a substring of length 5 and remove the complement spaces from the returned result set.

Related function:

left()

right()