STRMID

The STRMID function extracts a substring from a string expression. The result of the function is a string of Length characters taken from Expression , starting at character position First_Character .

Calling Sequence

Result = STRMID( Expression, First_Character [, Length ] )

Arguments

Expression

The expression from which the substring is to be extracted. If this argument is not a string, it is converted using IDL's default formatting rules. If Expression is an array, the result is an array with the same structure, where each element contains the substring of the corresponding Expression element.

First_Character

The starting position within Expression at which the substring starts. The first character position is 0.

Length

The length of the substring. If there are not enough characters left in the main string to obtain Length characters, the substring is truncated. If Length is not supplied, STRMID extracts all characters from the specified start position to the end of the string.

Example

If the variable B contains the string "IDL is fun", the substring "is" can be extracted and stored in the variable C with the command:

C = STRMID(B, 4, 2)

See Also

RSTRPOS , STRPOS , STRPUT , STRTRIM