Re: [GENERAL] regex help wanted

2013-04-28 Thread matt
> On 2013-04-25, Karsten Hilbert wrote: >> On Thu, Apr 25, 2013 at 10:32:26AM -0400, Tom Lane wrote: >> >>> Karsten Hilbert writes: >>> > What I don't understand is: Why does the following return a >>> > substring ? >>> >>> > select substring ('junk $$ junk' from >>> '\$<[^<]+?::[^:]+?>\$'); >>

Re: [GENERAL] regex help wanted

2013-04-27 Thread Jasen Betts
On 2013-04-25, Karsten Hilbert wrote: > On Thu, Apr 25, 2013 at 10:32:26AM -0400, Tom Lane wrote: > >> Karsten Hilbert writes: >> > What I don't understand is: Why does the following return a >> > substring ? >> >> >select substring ('junk $$ junk' from >> > '\$<[^<]+?::[^:]+?>\$'); >> >>

Re: [GENERAL] regex help wanted

2013-04-25 Thread Tom Lane
Karsten Hilbert writes: > 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 ?

Re: [GENERAL] regex help wanted

2013-04-25 Thread Karsten Hilbert
On Thu, Apr 25, 2013 at 03:40:51PM +0100, Thom Brown wrote: > On 25 April 2013 15:32, Tom Lane wrote: > > Karsten Hilbert writes: > >> What I don't understand is: Why does the following return a > >> substring ? > > > >> select substring ('junk $$ junk' from > >> '\$<[^<]+?::[^:]+?>\$');

Re: [GENERAL] regex help wanted

2013-04-25 Thread Karsten Hilbert
On Thu, Apr 25, 2013 at 10:32:26AM -0400, Tom Lane wrote: > Karsten Hilbert writes: > > What I don't understand is: Why does the following return a > > substring ? > > > select substring ('junk $$ junk' from > > '\$<[^<]+?::[^:]+?>\$'); > > There's a perfectly valid match in which [^<]+? m

Re: [GENERAL] regex help wanted

2013-04-25 Thread Thom Brown
On 25 April 2013 15:32, Tom Lane wrote: > Karsten Hilbert writes: >> What I don't understand is: Why does the following return a >> substring ? > >> select substring ('junk $$ junk' from >> '\$<[^<]+?::[^:]+?>\$'); > > There's a perfectly valid match in which [^<]+? matches allergy::test >

Re: [GENERAL] regex help wanted

2013-04-25 Thread Tom Lane
Karsten Hilbert writes: > What I don't understand is: Why does the following return a > substring ? > select substring ('junk $$ junk' from > '\$<[^<]+?::[^:]+?>\$'); There's a perfectly valid match in which [^<]+? matches allergy::test and [^:]+? matches 99. rega

[GENERAL] regex help wanted

2013-04-25 Thread Karsten Hilbert
Hi, I am in the process of converting some TEXT data which I try to identify by regular expression. What I don't understand is: Why does the following return a substring ? select substring ('junk $$ junk' from '\$<[^<]+?::[^:]+?>\$'); I would have thought the '::[^:]+?>' part should ha