Re: Referencing parts captured by round brackets in a regex in 8.4.13

From: Alban Hertroys <haramrae(at)gmail(dot)com>
To: Alexander Farber <alexander(dot)farber(at)gmail(dot)com>
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: Referencing parts captured by round brackets in a regex in 8.4.13
Date: 2013-03-22 15:22:21
Message-ID: CAF-3MvM8mA_u-KrUDcXXJv4bh+XpqnK+HbN0_R0GjJTVc=kPPA@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 22 March 2013 16:08, Alexander Farber <alexander(dot)farber(at)gmail(dot)com> wrote:

> Thank you, this works better, but -

> the result is correctly "true" now,
> but the warning is still there, why?
>
> # select 'axxxxxyz' ~ '(.)\\1\\1';
> WARNING: nonstandard use of \\ in a string literal
> LINE 1: select 'axxxxxyz' ~ '(.)\\1\\1';
> ^
> HINT: Use the escape string syntax for backslashes, e.g., E'\\'.
> ?column?
> ----------
> t
> (1 row)

Because backslash is not normally a valid escape character in an SQL string
literal.

You can turn off the warning in your settings, or you can be explicit about
wanting a string literal that can include such escape characters by using
the E'<string>' notation.

I seem to recall that there's a string literal notation specific to regular
expressions as well (R'<regular expression>'?), but I may be mixing up
databases...

--
If you can't see the forest for the trees,
Cut the trees and you'll see there is no forest.

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2013-03-22 15:46:31 Re: Rewritten rows on unchanged values
Previous Message Victor Yegorov 2013-03-22 15:13:58 Re: Referencing parts captured by round brackets in a regex in 8.4.13