Using the fixed position specifier

The fixed position specifier is positioned at a particular operand in the input string.

Sometimes it is necessary to position the pattern matching at a particular operand in the input string. This is handled by the %n fixed position specifier. Examples of the fixed position specifier are:

Fixed Position Specifier Value
%1 Matches to the first token
%2 Matches to the second token
%–1 Matches to the last token
%–2 Matches to the second from last token

The positions can be qualified by following the %n with a token type. Some examples are:

Fixed Position Specifier Value
%2^ Matches to the second numeric token
%-1^ Matches to the last numeric token
%3T Matches to the third street type token
%2? Matches to the second set of two or more unknown alphabetic tokens

You can use the fixed position specifier (%) in only two ways:

  • As the first operand of a pattern
  • As the first and second operands of a pattern

The following pattern is allowed and matches the second numeric token as operand [1] and the third leading alpha token that follows as operand [2]:


%2^ | %3<

The fixed position specifier treats each token according to its class. The following examples illustrate how to use the fixed position specifier for the input field:


John Doe 
123 Martin Luther St 
Salt Lake
Fixed Position Specifier Description
%1 1 Matches to the first word in the first string: JOHN
%1 2 Matches to the second word in the first string: DOE
%2 ? Matches to the second string of unknown alphabetic words: MARTIN LUTHER
%2 1 Matches to the first word in the second string: MARTIN
%-2 –1 Matches to the last word in the next to the last string: LUTHER
%3+ Matches to the third single alphabetic word: MARTIN
%–1 ? Matches to the last string of unknown alphabetic words: SALT LAKE
%–1+ Matches to the last single alphabetic word: LAKE

The position specifier does not continue scanning if a pattern fails to match (unlike * and #).

Assuming the input value S is classified as a D for direction, the following pattern matches the 789 S in the string 123 A 456 B 789 S:


%3^ | D

That same pattern does not match 123 A 456 B 789 C 124 S because the third number (789) is not followed by a direction.