Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate - Mailing list pgsql-hackers

From Florian Pflug
Subject Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate
Date
Msg-id 1EF239C0-863E-4631-95E5-52CD8D1DE3CE@phlo.org
Whole thread Raw
In response to Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate  ("David E. Wheeler" <david@kineticode.com>)
List pgsql-hackers
On Jun20, 2011, at 18:28 , David E. Wheeler wrote:
> I don't suppose there's a special quoting to be had for patterns? Perhaps one of these (modulo SQL parsing issues);
>
>    /pattern/
>    {pattern}
>    qr/pattern/
>    qr'pattern'
>    R/pattern/
>    R'pattern'

Pretty daring suggestion, I must say ;-)

I think regexp's are nearly prominent enough in SQL to warrant this.
Also, the main reason why this is such a huge deal for most programming
languages is that it avoids having to double-escape backslashes.

At least with standard_conforming_strings=on, however, that isn't a problem
in SQL because backslashes in literals aren't treated specially. For example
writing 'test' ~ '^\w+$'
Just Works (TM) if standard_conforming_strings=on, whereas in C you'd
have to write regexp_match("test", "^\\w+$")
to give the regexp engine a chance to even see the "\".

best regards,
Florian Pflug



pgsql-hackers by date:

Previous
From: "David E. Wheeler"
Date:
Subject: Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate
Next
From: Florian Pflug
Date:
Subject: Re: proposal: a validator for configuration files