[Info-ingres] Using a literal '-' in a character class
Roy Hann
specially at processed.almost.meat
Tue Jan 15 10:44:54 UTC 2019
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'.
More information about the Info-ingres
mailing list