Previous Topic

Next Topic

Book Contents

Book Index

Overview of %%$PARSE

The %%$PARSE function parses a specified string (that is, it splits the specified string into substrings) according to a specified template. A template consists of variables and "patterns" that determine the parsing process.

The format of the %%$PARSE function is

DO SET=%%$PARSE string template

In this format

DO SET=%%S=THIS IS A SAMPLE STRING

DO SET=%%T=A1 A2 A3 A4 A5

DO SET=%%$PARSE %%S %%T

The %%$PARSE function assigns substrings of the specified string to the specified variables according to the specified template.

The DO SET statements in the above example provide the same result as the following DO SET statements:

DO SET=%%A1=THIS

DO SET=%%A2=IS

DO SET=%%A3=A

DO SET=%%A4=SAMPLE

DO SET=%%A5=STRING

The parsing process involves the following stages:

  1. The string is broken into substrings, from left to right, using the patterns in the template.
  2. Each substring is parsed into words, from left to right, using the variable names in the template.

Template elements are

The rules of parsing are detailed in the following paragraphs.

Parent Topic

%%$PARSE Function