Parsing is the act of breaking apart one piece of data into separate pieces. For example, let's say that the value of the variable My_Variable is the string This is some data. You wish to break this apart so that each word is assigned to a different variable. You use the PARSE instruction to do this.

By default, PARSE breaks apart data wherever there is at least one blank space. So, the first piece of data that PARSE breaks off of My_Variable's value is the word This. This process is referred to as "tokenization", and so This is the first token (ie, piece). The second token (ie, second piece of data that PARSE breaks off) is the word is. The third token is some, and the fourth (and last token) is data. PARSE trims any leading and trailing spaces from each token that is broken off, except for the last token. (Although one leading space upon the last token is eaten by the parsing process).

But as you'll see later, you can use the PARSE instruction to break up a string of data in many other ways. For example, you can choose to break it apart at characters and patterns other than a space, or break it apart into pieces of particular lengths, etc. Most anyway you can think of to break apart a string of data can be done with a PARSE instruction.

One of the following keywords must follow the PARSE keyword: ARG, PULL, VAR, SOURCE, VERSION, LINEIN, or VALUE. Which one you use depends upon where you're getting the data being broken apart, and how you want it broken apart. You can also use the keyword UPPER in conjunction with any of the preceding keywords in order to tell REXX to change all lower case letters to upper case in any tokens that are broken off. Reginald allows you to alternately use the keyword CASELESS to not alter the case of any tokens, but allow your search strings (discussed later) to match any case.

The following sections detail the many variations and uses of the PARSE instruction.