substr (AutoLISP)

Returns a substring of a string

Supported Platforms: Windows and Mac OS

Signature

(substr str start [length])
str

Type: String

A textual value.

start

Type: Integer

A positive numeric value indicating the starting position in str. The first character in the string is position 1.

length

Type: Integer

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

Return Values

Type: String

A substring from str.

Remarks

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

Note: The first character of str 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.

Example

(substr "abcde" 2)
"bcde"

(substr "abcde" 2 1)
"b"

(substr "abcde" 3 2)
"cd"