Product SiteDocumentation Site

9.8.2. Combining String and Positional Patterns

There is a special case in which absolute and relative positional patterns do not work identically. Parsing with a template containing a string pattern skips the data in the source string that matches the pattern (see Section 9.2, “Templates Containing String Patterns”). But a template containing the sequence string pattern, variable name, and relative position pattern does not skip the matching data. A relative positional pattern moves relative to the first character matching a string pattern. As a result, assignment includes the data in the source string that matches the string pattern.

Example 9.24. Combining string and positional patterns

/* Template containing string pattern, then variable name, then  */
/*  relative positional pattern does not skip any data.          */
string="REstructured eXtended eXecutor"
parse var string var1 3 junk "X" var2 +1 junk "X" var3 +1 junk
say var1||var2||var3 /* Concatenates variables; displays: "REXX" */

Here is how this template works: