pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: T E Schmitz <mailreg@numerixtechnology.de>
To: Rodrigo De Leon <rdeleonp@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SELECT substring with regex
Date: Sat, 08 Jul 2006 10:40:08 +0100
Message-ID: <44AF7D78.2050007@numerixtechnology.de> (raw)
In-Reply-To: <a55915760607071824k65a09b3ahd52b16bdd59108b8@mail.gmail.com>
References: <44AE66E0.1040606@numerixtechnology.de>
	<200607071659.14940.gary.stainburn@ringways.co.uk>
	<44AE9B4F.1020401@numerixtechnology.de>
	<a55915760607071137q2c70346cp5b30cac14beaf1e7@mail.gmail.com>
	<44AEB4C6.9000903@numerixtechnology.de>
	<a55915760607071824k65a09b3ahd52b16bdd59108b8@mail.gmail.com>

Rodrigo De Leon wrote:
> On 7/7/06, T E Schmitz <mailreg@numerixtechnology.de> wrote:
> 
>> Sorry, but that would also capture something like
>> 10-30-59mm
>>
>> The pattern describes either a single length (120 millimeters) or a
>> range (30 to 70 millimetres), hence:
>>
>> \\d+(-\\d+)?mm
>>
>> The ? quantifier refers to the combination of '-' and digits and has to
>> be bracketed.
>>
>> ...
>>
>> Still, I'd be interested to know whether there is a 'more elegant' 
>> solution.
> 
> 
> OK, last try using regex:
> 
> SELECT
> NAME
> , substring(NAME, '^(\\d+(-\\d+)?mm)') AS BASE_NAME
> , regexp_replace(NAME, '^\\d+(-\\d+)?mm (.*)', '\\2') AS SUFFIX
> FROM MODEL

Is regexp_replace a new feature?
I am running v 7.4.

-- 


Regards,

Tarlika



view thread (20+ messages)  latest in thread

Message-ID: <44AF7D78.2050007@numerixtechnology.de>
Permalink:  ../44AF7D78.2050007@numerixtechnology.de/
Also on:    postgresql.org/message-id/44AF7D78.2050007@numerixtechnology.de

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-sql@postgresql.org
  Cc: mailreg@numerixtechnology.de, rdeleonp@gmail.com
  Subject: Re: SELECT substring with regex
  In-Reply-To: <44AF7D78.2050007@numerixtechnology.de>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox