Re: Backslash Bug in ARE Class-Shorthand Escape?

From: Joe Conway <mail(at)joeconway(dot)com>
To: David Fetter <david(at)fetter(dot)org>
Cc: pgsql-bugs(at)postgresql(dot)org
Subject: Re: Backslash Bug in ARE Class-Shorthand Escape?
Date: 2003-12-06 08:15:28
Message-ID: 3FD19020.6020407@joeconway.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

David Fetter wrote:
> I have a little puzzlement. In the first select, I double the
> backslash and return true. In the second, I don't and get false.
> Have I missed something important in the docs?

I don't know if it is clear in the docs anywhere wrt regex, but the
string literal parser will consume one layer of backslashes on you. So
in your first case '\\d' is fed into the regex matching function as '\d'
(string literal parser sees \\ == escape \ == \), and in the second case
'\d' is fed in as 'd' (string literal parser sees \d == escape d == d).
The basic rule at work here is you need to double up all backslashes.

HTH,

Joe

In response to

Responses

Browse pgsql-bugs by date

  From Date Subject
Next Message Peter Eisentraut 2003-12-06 08:21:35 Re: Backslash Bug in ARE Class-Shorthand Escape?
Previous Message David Fetter 2003-12-06 07:23:29 Backslash Bug in ARE Class-Shorthand Escape?