Matches a specifiedstring to an existing regular expression.
expr
0 Indicates no match.
grep
. Using Grep is equivalent to specifying a Syntax value of 20.Egrep
egrep
. Using Egrep is equivalent to specifying a Syntax value of 51.Exact
Length
Position
If string is an array of strings, the return values of Length and Position are arrays with the same structure as string.
Syntax
NOTE: STRMATCH uses regular expressions, not wildcard characters, for pattern matching. To use STRMATCH, it is crucial that you understand regular expressions. For a detailed discussion of regular expressions, see the chapter Working with Text in the PV-WAVE Programmer's Guide.
awk
. This is equivalent to specifying a Syntax value of 35. Keywords are used so STRMATCH uses a syntax compatible with the UNIX commands grep
or egrep
; or a completely arbitrary syntax can be specified using Syntax. The following table lists information pertinent to Syntax.
x = '' & READ, 'Enter a letter or number: ', x
IF NOT STRMATCH(x, '[a-zA-Z0-9]', /Exact) THEN PRINT, 'Invalid response.'
name = 'Smith, Bill J.' IF STRMATCH(name, '^(.*), *(.*)$', reg) THEN name = reg(2) + ' ' + reg(1)
PRINT, name
Bill J. Smith
owners = ['Bill', 'Kathy', 'Janis', 'Ken'] pets = ['cat', 'rabbit', 'fish', 'dog']
w = STRMATCH(pets, 'cat|dog') PRINT, owners(WHERE(w)), Format='(A)'
Bill
Ken