pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Aaron Bono <postgresql@aranya.com>
To: Rodrigo De Leon <rdeleonp@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: SELECT substring with regex
Date: Fri, 7 Jul 2006 14:45:51 -0500
Message-ID: <bf05e51c0607071245w3738e109l8128d345f5b06977@mail.gmail.com> (raw)
In-Reply-To: <a55915760607071137q2c70346cp5b30cac14beaf1e7@mail.gmail.com>
References: <44AE66E0.1040606@numerixtechnology.de>
	<200607071659.14940.gary.stainburn@ringways.co.uk>
	<44AE9B4F.1020401@numerixtechnology.de>
	<a55915760607071137q2c70346cp5b30cac14beaf1e7@mail.gmail.com>

On 7/7/06, Rodrigo De Leon <rdeleonp@gmail.com> wrote:
>
> On 7/7/06, T E Schmitz <mailreg@numerixtechnology.de> wrote:
> > But that takes me to the next problem:
> >
> > For the sake of the example I simplified the regular pattern.
> > In reality, BASE_NAME might be:
> >
> > 28mm
> > 28-70mm
> >
> > So the reg. expr. requires brackets:
> >
> > substring (NAME, '^(\\d+(-\\d+)?mm)' ) as BASE_NAME
> >
> > Actually, the pattern is more complex than that and I cannot see how I
> > can express it without brackets.
>
> Maybe:
>
> select
> substring ('150mm LD AD Asp XR Macro', '^[\\d-]*mm' ) as BASE_NAME
> , substring('150mm LD AD Asp XR Macro','^[\\d-]*mm (.*)$') as SUFFIX;
>
> select
> substring ('28-70mm LD AD Asp XR Macro', '^[\\d-]*mm' ) as BASE_NAME
> , substring('28-70mm LD AD Asp XR Macro','^[\\d-]*mm (.*)$') as SUFFIX;
>
> etc...
>
> Regards,
>
> Rodrigo


Is there a reason this column wasn't separated into two different columns?
Or perhaps into a child table if there could be more than one XXXmm value in
the field?

Just curious.

-Aaron

view thread (20+ messages)  latest in thread

Message-ID: <bf05e51c0607071245w3738e109l8128d345f5b06977@mail.gmail.com>
Permalink:  ../bf05e51c0607071245w3738e109l8128d345f5b06977@mail.gmail.com/
Also on:    postgresql.org/message-id/bf05e51c0607071245w3738e109l8128d345f5b06977@mail.gmail.com

 · 

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: postgresql@aranya.com, rdeleonp@gmail.com
  Subject: Re: SELECT substring with regex
  In-Reply-To: <bf05e51c0607071245w3738e109l8128d345f5b06977@mail.gmail.com>

* 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