Extracts a substring from a string expression.
If not of type string, expr is converted to string using the default formatting rules of PV-WAVE. (These rules are described in Free Format Output in Chapter 8 of the PV-WAVE Programmer's Guide.)
first_character The starting position within expr at which the substring starts. The first character position is position 0.
a = 'Extract a substring from a string'
Create a string in the variable
a
.
POS = STRPOS(a, 'a ')
Locate first occurrence of the string "a ".
PRINT, STRMID(a, pos, 11)
a substring
Extract 11 characters from
a
, starting at POS.
POS = STRPOS(a, 'a ', pos + 1)
Search for the second occurrence of the string "a " by searching
; from the character position that is one greater than the first
; occurrence of that string. Extract 8 characters from
a
, starting at the
; new POS.
PRINT, STRMID(a, pos, 8)
a string