Re: SELECT substring with regex - Mailing list pgsql-sql

From Rodrigo De Leon
Subject Re: SELECT substring with regex
Date
Msg-id a55915760607071137q2c70346cp5b30cac14beaf1e7@mail.gmail.com
Whole thread Raw
In response to Re: SELECT substring with regex  (T E Schmitz <mailreg@numerixtechnology.de>)
Responses Re: SELECT substring with regex
Re: SELECT substring with regex
List pgsql-sql
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


pgsql-sql by date:

Previous
From: Stephan Szabo
Date:
Subject: Re: Atomar SQL Statement
Next
From: Scott Marlowe
Date:
Subject: Re: Atomar SQL Statement