Version 0.59.0

str::substr

Extracts characters from a string.

Signatures

  •   string substr( string& input, int start, int end )

Details

The substr() function extracts characters from a string between indices start and end, not including end itself, and returns the new sub string.

Example

 #import( "std/str.sps" )
 string s = "Hello World!";
 echo( str::substr( s, 1, 4 ) );
 

Output

 ell
 

Return value

A new string containing the extracted characters.

Parameters

input

The string the substring is extracted from.

start

The position where to start the extraction. First character is at index 0.

end

The position (up to, but not including) where to end the extraction.

See also

🗙

Search results for