BUG #3788: POSIX regexp seems doesn't work for '(?!re) ' pattern

Started by Vitalyover 18 years ago2 messagesbugs
Jump to latest
#1Vitaly
vitaly.yakunin@gmail.com

The following bug has been logged online:

Bug reference: 3788
Logged by: Vitaly
Email address: vitaly.yakunin@gmail.com
PostgreSQL version: 8.3-beta3
Operating system: WinXP
Description: POSIX regexp seems doesn't work for '(?!re) ' pattern
Details:

SELECT author, type
FROM books WHERE "type" ~ '(?!novel)';

This select work incorrect. It returns all types.

Work around:
SELECT author, type
FROM books WHERE not ("type" ~ '(?=novel)');

#2Tom Lane
tgl@sss.pgh.pa.us
In reply to: Vitaly (#1)
Re: BUG #3788: POSIX regexp seems doesn't work for '(?!re) ' pattern

"Vitaly" <vitaly.yakunin@gmail.com> writes:

SELECT author, type
FROM books WHERE "type" ~ '(?!novel)';

This select work incorrect. It returns all types.

Certainly. That's a negative-lookahead pattern and is therefore
guaranteed to match somewhere in every string (at the end, if
nowhere else).

regards, tom lane