Shiny Language Reference

Language Reference > String Functions


strmid

string strmid(string Target, int Start, int Chars);

 

Synonyms:

string mid(string Target, int Start, int Chars);
 

Returns N chars from position P in the supplied string

STRMID returns N characters from the supplied string, beginning from zero based position P. This function is equivalent to the Visual Basic "Mid" function or the STL string::substr function.

The dual syntax MID can be used in place of STRMID.

 

Parameters

Target

The string to return a substring from

Start

The zero based position to start returning characters from. If this position is invalid, the original string will be returned.

Chars

The number of characters to return. If -1 or a value larger than the number of characters in the target is specified, STRMID assume this parameter to mean "To the end of the string".

 

Return Value

The substring of N characters from position P of the target string.

 

Example Code

// SubString will contain "is"
string SubString = strmid("This is a test", 5, 2);

// Equivalent dual-syntax use
string SubString = mid("This is a test", 5, 2);