substr (AutoLISP)

Returns a substring of a string

(substr string start [length])

The substr function starts at the start character position of string and continues for length characters.

Arguments

string

A string.

start

A positive integer indicating the starting position in string. The first character in the string is position 1.

length

A positive integer specifying the number of characters to search through in string. If length is not specified, the substring continues to the end of string.

Note: The first character of string is character number 1. This differs from other functions that process elements of a list (like nth and ssname ) that count the first element as 0.

Return Values

A string.

Examples

Command: (substr "abcde" 2)

"bcde"

Command: (substr "abcde" 2 1)

"b"

Command: (substr "abcde" 3 2)

"cd"