Introducing the Escape character


Since, even when they are inside quotes, '*' and '?' are treated as wildcard characters, you need a mechanism to handle situations where you want to test for the presence of these characters. This is done as follows:

  • If you want to treat a question mark or an asterisk as a normal character, you must use the escape character double quote ' " ' in front of it.
  • A question mark or asterisk immediately following the escape character is treated as a normal character. The following pattern:

    $PGMR(AB"?C)

    therefore matches this string:

    AB?C

    but not these strings:

    AB C
    ABBC

Of course, the existence of an escape character raises the issue of how to test for the escape character itself. Again, the rules are familiar:

  • If you want to match on the escape character then use two double quote ' "" ' characters in succession.
  • The character following the escape character (") must be either a wildcard character (* or ?) or another escape character ("). Any other character is flagged as an error.

Several more detailed examples that will emphasize the effects of these rules are shown in subsequent sections.


 

Tip: For faster searching, add an asterisk to the end of your partial query. Example: cert*