In cases where data to be matched might or might not exist in the input, use the maybe operator, which is a question mark (?). The maybe operator indicates that a pattern matches regardless of whether the matching data exists. ASL assigns a NULL string to a variable if a pattern with a maybe operator has no match.

The following script matches an employee number (an integer) and a name (of multiple words). The first and third lines of input match. An employee ID and a name exists. Even though there is no employee ID number, the second input line matches because ASL assigns the variable a NULL string.

ASL Script (0to1_match.asl):
/* (The rep keyword indicates Repeated Pattern Matches) */
 a:integer? b:rep(word) eol
do {
 print("Employee ".b);
 print("Employee ID ".a);
do {
 print("Failed match");
Input (0to1_match.txt):
4120 Kathy Jones
John L. Doe
3901 David Smith
$ sm_adapter --file=0to1_match.txt 0to1_match.asl
Employee Kathy Jones
Employee ID 4120
Employee John L. Doe
Employee ID 
Employee David Smith
Employee ID 3901