Re: [GENERAL] regex help wanted

2013-04-28 Thread matt
On 2013-04-25, Karsten Hilbert karsten.hilb...@gmx.net wrote: On Thu, Apr 25, 2013 at 10:32:26AM -0400, Tom Lane wrote: Karsten Hilbert karsten.hilb...@gmx.net writes: What I don't understand is: Why does the following return a substring ? select substring ('junk $allergy::test::99$

Re: [GENERAL] regex help wanted

2013-04-27 Thread Jasen Betts
On 2013-04-25, Karsten Hilbert karsten.hilb...@gmx.net wrote: On Thu, Apr 25, 2013 at 10:32:26AM -0400, Tom Lane wrote: Karsten Hilbert karsten.hilb...@gmx.net writes: What I don't understand is: Why does the following return a substring ? select substring ('junk $allergy::test::99$

[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 $allergy::test::99$ junk' from '\$[^]+?::[^:]+?\$'); I would have thought the '::[^:]+?'

Re: [GENERAL] regex help wanted

2013-04-25 Thread Tom Lane
Karsten Hilbert karsten.hilb...@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

Re: [GENERAL] regex help wanted

2013-04-25 Thread Thom Brown
On 25 April 2013 15:32, Tom Lane t...@sss.pgh.pa.us wrote: Karsten Hilbert karsten.hilb...@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

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 karsten.hilb...@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

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 t...@sss.pgh.pa.us wrote: Karsten Hilbert karsten.hilb...@gmx.net writes: What I don't understand is: Why does the following return a substring ? select substring ('junk

Re: [GENERAL] regex help wanted

2013-04-25 Thread Tom Lane
Karsten Hilbert karsten.hilb...@gmx.net 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 ? Or