Re: order of (escaped) characters in regex range

Поиск
Список
Период
Сортировка
От David Johnston
Тема Re: order of (escaped) characters in regex range
Дата
Msg-id 032001ccb9b7$b089b3f0$119d1bd0$@yahoo.com
обсуждение исходный текст
Ответ на Re: order of (escaped) characters in regex range  (Merlin Moncure <mmoncure@gmail.com>)
Ответы Re: order of (escaped) characters in regex range
Список pgsql-general
-----Original Message-----
From: pgsql-general-owner@postgresql.org
[mailto:pgsql-general-owner@postgresql.org] On Behalf Of Merlin Moncure
Sent: Tuesday, December 13, 2011 11:39 AM
To: rob@marjot-multisoft.com
Cc: David Johnston; Szymon Guz; pgsql-general
Subject: Re: [GENERAL] order of (escaped) characters in regex range

On Tue, Dec 13, 2011 at 7:51 AM, InterRob <rob.marjot@gmail.com> wrote:
> Thanks guys, i see what you mean.
>
> I do intend to use the PG escaping, in order to avoid that annoying
> warning... Hence, my expression should indeed be:
> SELECT regexp_matches('123-A' , E'(3[A-Z\\-\\(\\) ])');
>
> In the above expression i added the parentheses as I whish to match
> these as well :))

I advise dollar quoting when writing complicated regular expressions:

E'(3[A-Z\\-\\(\\) ])'
becomes
$$(3[A-Z\-\(\) ])$$

merlin

--
Sent via pgsql-general mailing list (pgsql-general@postgresql.org) To make
changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general

---------------------------------------------------------------

Aside from backward compatibility, and the various warnings, is there any
reason to prefer dollar-quoting over a non-SQL-escaped string literal (i.e.,
'3[A-Z\-\(\) ]'   ) ?

David J.



В списке pgsql-general по дате отправления:

Предыдущее
От: Merlin Moncure
Дата:
Сообщение: Re: order of (escaped) characters in regex range
Следующее
От: Scot Kreienkamp
Дата:
Сообщение: Re: initdb with lc-collate=C