Tinderbox v9 Icon

substr(dataStr, startNum[, lengthNum])

Operator Type: 

Operator Scope of Action: 

Operator Purpose: 

Operator First Added: 

Operator Last Altered: 

Operator Has Optional Arguments: 

Operator Has Newer Dot-Operator Variant: 

 Function  [other Function type actions]

 Item  [operators of similar scope]

 Data manipulation  [other Data manipulation operators]


 As at baseline

 [More on optional operator arguments]


substr(dataStr, startNum, lengthNum)

Where dataStr is a string literal, string attribute or expression evaluating to a string.

Where startNum is the zero-based position to start the substring. Negative startNum values are not supported, though String.substring() does so and may be used instead.

Where lengthNum is the length of the returned string. If not specified, the entire string from (or back from) startNum is returned.

Extracts a substring of data. For example:

$MyString = substr("test",0,1); 

returns "t", while

$MyString = substr("test",1,2); 

returns "es". All arguments are evaluated; if the designated characters do not exist, an empty string is returned.

If the length of the substring is negative, it is treated as an offset from the end of the string.

$MyString = substr("Hello",1,-1); → "ell"

Note that in expressions like


the value of $Name is not changed.