Another positional matching function is len(). The len() function advances the starting position from its current position, unlike the tab() function that works from the original starting position when the START rule is invoked. The syntax is as follows:


The value of <char_num> is the number of characters to advance from its current position. If <char_num> is not specified, the function returns the value of the position where the parser would start to test a pattern.

Like the tab() function, use of the assignment operator assigns all characters skipped to the variable. The len() function does not skip over markers.

In Example of positional matching, because of the white space operator between each variable assignment, the space between fox and jumps is skipped. The len() function starts with the letter j. It ends at position 14, forcing tab (14) to return an empty string. This problem could be avoided by eliminating the delimiters, as described in “Customizing the delimiter” on page 67.

Figure 1. Example of positional matching