Re: regex help wanted

Поиск
Список
Период
Сортировка
От Jasen Betts
Тема Re: regex help wanted
Дата
Msg-id kli9oq$odq$1@gonzo.reversiblemaps.ath.cx
обсуждение исходный текст
Ответ на regex help wanted  (Karsten Hilbert <Karsten.Hilbert@gmx.net>)
Ответы Re: regex help wanted
Список pgsql-general
On 2013-04-25, Karsten Hilbert <Karsten.Hilbert@gmx.net> wrote:
> On Thu, Apr 25, 2013 at 10:32:26AM -0400, Tom Lane wrote:
>
>> Karsten Hilbert <Karsten.Hilbert@gmx.net> writes:
>> > What I don't understand is: Why does the following return a
>> > substring ?
>>
>> >     select substring ('junk $<allergy::test::99>$ junk' from '\$<[^<]+?::[^:]+?>\$');
>>
>> There's a perfectly valid match in which [^<]+? matches allergy::test
>> and [^:]+? matches 99.
>
> Tom, thanks for helping !
>
> I would have thought "<[^<]+?:" should mean:
>
>     match a "<"
>     followed by 1-n characters as long as they are not "<"
>     until the VERY NEXT ":"


if you want that say:  "<[^<:]+:"

> The "?" should make the "+" after "[^<]" non-greedy and thus
> stop at the first occurrence of ":", right ?  Or am I
> misunderstanding that part ?

From "the fine manual"

 Non-greedy quantifiers (available in AREs only) match the same
 possibilities as their corresponding normal (greedy) counterparts, but
 prefer the smallest number rather than the largest number of matches.
 See Section 9.7.3.5 for more detail.



--
⚂⚃ 100% natural

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

Предыдущее
От: Jasen Betts
Дата:
Сообщение: Re: Optimizing bulk update performance
Следующее
От: Bob Futrelle
Дата:
Сообщение: pgAdmin shows two servers with the identical data