Re: regex help wanted

Поиск
Список
Период
Сортировка
От Karsten Hilbert
Тема Re: regex help wanted
Дата
Msg-id 20130425144509.GI3802@hermes.hilbert.loc
обсуждение исходный текст
Ответ на Re: regex help wanted  (Tom Lane <tgl@sss.pgh.pa.us>)
Ответы Re: regex help wanted  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-general
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 ":"

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

At any rate,

    select substring ('junk $<allergy::test::99>$ junk' from '\$<[^<:]+?::[^:]+?>\$');

(which follows from your hint) appears to do what I need.

Thanks,
Karsten
--
GPG key ID E4071346 @ gpg-keyserver.de
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


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

Предыдущее
От: Thom Brown
Дата:
Сообщение: Re: regex help wanted
Следующее
От: Karsten Hilbert
Дата:
Сообщение: Re: regex help wanted