Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate

Поиск
Список
Период
Сортировка
От Florian Pflug
Тема Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate
Дата
Msg-id 1EF239C0-863E-4631-95E5-52CD8D1DE3CE@phlo.org
обсуждение исходный текст
Ответ на Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate  ("David E. Wheeler" <david@kineticode.com>)
Список 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 по дате отправления:

Предыдущее
От: "David E. Wheeler"
Дата:
Сообщение: Re: Adding a distinct "pattern" type to resolve the "~" commutator stalemate
Следующее
От: Florian Pflug
Дата:
Сообщение: Re: proposal: a validator for configuration files