Re: Backslash Bug in ARE Class-Shorthand Escape? - Mailing list pgsql-bugs

From Joe Conway
Subject Re: Backslash Bug in ARE Class-Shorthand Escape?
Date
Msg-id 3FD19020.6020407@joeconway.com
Whole thread Raw
In response to Backslash Bug in ARE Class-Shorthand Escape?  (david@fetter.org (David Fetter))
Responses Re: Backslash Bug in ARE Class-Shorthand Escape?  (Joe Conway <mail@joeconway.com>)
List 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

pgsql-bugs by date:

Previous
From: david@fetter.org (David Fetter)
Date:
Subject: Backslash Bug in ARE Class-Shorthand Escape?
Next
From: Peter Eisentraut
Date:
Subject: Re: Backslash Bug in ARE Class-Shorthand Escape?