substr

substr has 1 variant:

Description

substr functions allows you to extract a substring from a string.

  • If start_position is 0, then the SUBSTR function treats start_position as 1 (ie: the first position in the string).

  • If start_position is a positive number, then the SUBSTR function starts from the beginning of the string.

  • If start_position is a negative number, then the SUBSTR function starts from the end of the string and counts backwards.

  • If length is a negative number, then the SUBSTR function will return a NULL value.

Declaration

char substr(char string, int startPosition, int length);

Parameters

Return Value

Example

char str;
str = substr("This is a test", 6, 2);

Result: "is"

See also

Last updated