The not() function acts as a logical NOT. If the pattern argument of the function matches, the not() function returns failure to the match. When the argument does not match, the not() function returns a successful match. The starting point does not advance when the not() function is used.

For example, the following script looks for input strings that do not contain the word horse.

  • If the word horse is found in the input string, the peek() function matches but the not() function returns a failed match. In this case, the rule GETLINE does not execute.

  • If the peek() function does not match, the not() function returns a successful match so the rule GETLINE executes.

    ASL Script (not_match.asl):
    START {
     not(peek(..'horse'))
     GETLINE
    }
    GETLINE{
     a:rep(word) eol
    }
    do {
     print("No horse: ".a);
    }
    DEFAULT {
     ..eol
    }
    do {
     print("Failed match");
    }
    Input (not_match.txt):
    moose horse camel
    elephant mule camel
    goat llama horse
    horse goat llama
    Output:
    $ sm_adapter --file=not_match.txt not_match.asl
    Failed match
    No horse: elephant mule camel
    Failed match
    Failed match
    $