With the tab() function, you can skip characters of input data by using the following syntax:
tab(<char_num>)
The value of <char_num> is the number of characters to skip from the starting position when the START rule is invoked. If <char_num> is not specified, the function returns the value of the position where the parser starts to test a pattern.
It is not possible to use the tab() function to move backward (right to left) in the datastream. For example, from the first position of a string, you use the tab() function to go to position 20, but, you then cannot go back to position 15. You cannot use the tab() function to return to data already parsed. Also, the tab() function does not skip over markers.
With the assignment operator (:), you can assign all of the characters skipped to the variable or the current position if no characters are specified by using the following syntax:
<variable>:tab(<char_num>)
In the following script, the tab() function in this pattern is used to skip the first and middle names. The parser goes directly to the last name of each person in the list. In the input datafile, each field has a fixed length. The last name field starts at position 16.
At position 16, a single word is matched and assigned to a variable. Then, the current starting position of the next pattern is returned. This position varies because the word lengths are not equal.
ASL Script (tab_match.asl): START { tab(16) lname:word locate:tab() eol } do { print("Last Name ".lname); print("Tab ".locate);} DEFAULT { ..eol } do { print("Failed match"); } Input (tab_match.txt): John Doe Jane Deborah Smith Output: $ sm_adapter --file=tab_match.txt tab_match.asl Last Name Doe Tab 19 Name Smith Tab 21 $