Substring

From Kolmafia
Revision as of 19:08, 11 March 2010 by imported>StDoodle (Created page with '{{ #vardefine:name|substring}}{{ #vardefine:return_type|string}}{{ FunctionPage| name={{#var:name}}| function_category=String Handling Routines| function1={{Function| name={{#v…')
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Function Syntax

string substring(string full ,int start ,int end )

  • full in the full string to extract from
  • find is the (optional) ending position

This function returns a portion of full, starting at start, and ending just before end. Note that end is optional; if omitted, the remainder of the string is returned. Both start, and optionally end are 0-indexed (but note that start is included in the returned portion, while end is not).

Code Sample

Returns a portion of a string.

substring( "Some big long line of text with no real purpose." , 10 , 12);

Would result in:

Returned: on

Special

If start and end are equal (and in-bounds), an empty string will be returned.