Re: psql can't subtract

From: Rob Sargent <robjsargent(at)gmail(dot)com>
To: depesz(at)depesz(dot)com
Cc: pgsql-general(at)postgresql(dot)org
Subject: Re: psql can't subtract
Date: 2011-03-25 17:05:53
Message-ID: 4D8CCB71.6090506@gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

On 03/25/2011 10:59 AM, hubert depesz lubaczewski wrote:
> On Fri, Mar 25, 2011 at 09:29:57AM -0600, Rob Sargent wrote:
>> Running 9.0.3 (client and server)
>>
>>
>> Seems I cannot subtract 1 from the result of position.
>>
>> select distinct
>> substring( substring(xml_text,1,300),
>> position( 'xmlns=' in substring(xml_text,1,300)) +
>> length('xmlns="'),
>> position( '"' in (substring(substring(xml_text,1,300),
>> position( 'xmlns=' in
>> substring(xml_text,1,300)) + length('xmlns="'),
>> 100)))
>> ) as namespace
>> from elements;
>
> is there any particular reason why you're writing something that
> complicated instead of using simple regexp?
>
> select distinct regexp_replace( xml_text, '.*xmlns="([^"]+)".*', E'\\1') from elements;
>
> Best regards,
>
> depesz
>

Just gross incompetency with regexps. Much thanks.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Marco 2011-03-25 17:05:59 Query with time zone offset but without seconds
Previous Message hubert depesz lubaczewski 2011-03-25 16:59:00 Re: psql can't subtract