[Info-ingres] Using a literal '-' in a character class

Martin Bowes martin.bowes at ndph.ox.ac.uk
Tue Jan 15 13:55:13 UTC 2019


Hi Roy,

FWIW: The behaviour of the dash is a problem in every damn reg Ex machine you can think of. Most of the ones I've played with over the years would suggest putting dash at the front of the pattern just to avoid these problems.

Marty

-----Original Message-----
From: Roy Hann [mailto:specially at processed.almost.meat] 
Sent: 15 January 2019 10:45
To: info-ingres at lists.planetingres.org
Subject: [Info-ingres] Using a literal '-' in a character class

I am looking at some existing code that wants find rows where an
attribute contains one of a set of special character, including
an ASCII dash.

The original code was similar to this:

  WHERE col LIKE '%\[.,;:\-&@\]%' ESCAPE '\'

which provoked the error message:

  E_AD1018 Illegal pattern match specified:  Illegal ESCAPE sequence.
    The ESCAPE char must be followed by one of:
        `%' (percent)
        `_' (underscore)
        `[' (left square bracket)
        `]' (right square bracket)
    another ESCAPE char.

Moving the dash to the start of the character class and not escaping it
works as intended, thus:

  WHERE col LIKE '%\[-.,;:&@\]%' ESCAPE '\'

So, my questions are: (1) did I get lucky and find a bug that works in
my favour. If not, (2) is this standard behaviour (i.e. ANSI/ISO
standard) that I can expect to work always everywhere?

Roy

PS: For the record, moving the '-' to the end does _not_ work. It
provokes a different error:

  E_AD1015 Illegal pattern match specified.  One of the following:
    o  An opening `[' without a closing `]'
        o  Vice-versa
        o  Range ending with `-]'
        o  Range of the form `[x-y]' where char `y' comes before `x'.


_______________________________________________
Info-ingres mailing list
Info-ingres at lists.planetingres.org
https://lists.planetingres.org/mailman/listinfo/info-ingres



More information about the Info-ingres mailing list