/* Alternative to period as placeholder
*/
stars='Arcturus Betelgeuse Sirius Rigil'
parse var stars drop junk brightest rest
/* brightest='Sirius' */
A placeholder saves the overhead of unneeded variables.
Templates Containing String Patterns
A
string pattern
matches characters in the source string to indicate where to split it. A string pattern can be
a:
Literal string pattern
One or more characters within quotation marks.
Variable string pattern
A variable within parentheses with no plus (
+
) or minus (
-
) or equal sign (
=
) before the left
parenthesis. (See page 209 for details.)
Here are two templates: a simple template and a template containing a literal string pattern:
var1 var2
/* simple template
*/
var1 ', ' var2
/* template with literal string pattern
*/
The literal string pattern is:
', '
. This template:
v
Puts characters from the start of the source string up to (but not including) the first character of the
match (the comma) into
var1
v
Puts characters starting with the character after the last character of the match (the character after the
blank that follows the comma) and ending with the end of the string into
var2
.
A template with a string pattern can omit some of the data in a source string when assigning data into
variables. The next two examples contrast simple templates with templates containing literal string
patterns.
/* Simple template
*/
name='Smith, John'
parse var name ln fn
/* Assigns: ln='Smith,' */
/*
fn='John'
*/
Notice that the comma remains (the variable
ln
contains
'Smith,'
). In the next example the template is
ln
', ' fn
. This removes the comma.
/* Template with literal string pattern
*/
name='Smith, John'
parse var name ln ', ' fn
/* Assigns: ln='Smith'
*/
/*
fn='John'
*/
First, the language processor scans the source string for ', '. It splits the source string at that point. The
variable
ln
receives data starting with the first character of the source string and ending with the last
character before the match. The variable
fn
receives data starting with the first character
after
the match
and ending with the end of string.
A template with a string pattern omits data in the source string that matches the pattern. (There is a
special case (on page 212) in which a template with a string pattern does
not
omit matching data in the
source string.) We used the pattern
', '
(with a blank) instead of
','
(no blank) because, without the
blank in the pattern, the variable
fn
receives ' John' (including a blank).
If the source string
does not contain a match for a string pattern
, then any variables preceding the
unmatched string pattern get all the data in question. Any variables after that pattern receive the null
string.
A null string is never found. It always matches the end of the source string.
Parsing
Chapter 15. Parsing
205
Summary of Contents for SC34-5764-01
Page 1: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 2: ......
Page 3: ...CICS Transaction Server for VSE ESA REXX Guide SC34 5764 01...
Page 22: ...xx CICS TS for VSE ESA REXX Guide...
Page 23: ...Part 1 User s Guide Copyright IBM Corp 1992 2009 1...
Page 24: ...2 CICS TS for VSE ESA REXX Guide...
Page 40: ...18 CICS TS for VSE ESA REXX Guide...
Page 54: ...Using Variables and Expressions 32 CICS TS for VSE ESA REXX Guide...
Page 106: ...84 CICS TS for VSE ESA REXX Guide...
Page 110: ...88 CICS TS for VSE ESA REXX Guide...
Page 122: ...100 CICS TS for VSE ESA REXX Guide...
Page 123: ...Part 2 Reference Copyright IBM Corp 1992 2009 101...
Page 124: ...102 CICS TS for VSE ESA REXX Guide...
Page 130: ...Introduction 108 CICS TS for VSE ESA REXX Guide...
Page 152: ...REXX General Concepts 130 CICS TS for VSE ESA REXX Guide...
Page 224: ...Functions 202 CICS TS for VSE ESA REXX Guide...
Page 252: ...230 CICS TS for VSE ESA REXX Guide...
Page 278: ...256 CICS TS for VSE ESA REXX Guide...
Page 312: ...DB2 Interface 290 CICS TS for VSE ESA REXX Guide...
Page 316: ...High level Client Server Support 294 CICS TS for VSE ESA REXX Guide...
Page 340: ...318 CICS TS for VSE ESA REXX Guide...
Page 344: ...for execs Commands 322 CICS TS for VSE ESA REXX Guide...
Page 399: ...Part 3 Appendixes Copyright IBM Corp 1992 2009 377...
Page 400: ...378 CICS TS for VSE ESA REXX Guide...
Page 438: ...416 CICS TS for VSE ESA REXX Guide...
Page 442: ...System Definition Customization Administration 420 CICS TS for VSE ESA REXX Guide...
Page 446: ...Security 424 CICS TS for VSE ESA REXX Guide...
Page 448: ...426 CICS TS for VSE ESA REXX Guide...
Page 464: ...442 CICS TS for VSE ESA REXX Guide...
Page 466: ...444 CICS TS for VSE ESA REXX Guide...
Page 468: ...446 CICS TS for VSE ESA REXX Guide...
Page 476: ...454 CICS TS for VSE ESA REXX Guide...
Page 478: ...456 CICS TS for VSE ESA REXX Guide...
Page 479: ......
Page 480: ...SC34 5764 01...
Page 481: ...Spine information CICS TS for VSE ESA REXX Guide...