| From: | "Rodrigo De Leon" <rdeleonp(at)gmail(dot)com> |
|---|---|
| To: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: SELECT substring with regex |
| Date: | 2006-07-07 18:37:08 |
| Message-ID: | a55915760607071137q2c70346cp5b30cac14beaf1e7@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
On 7/7/06, T E Schmitz <mailreg(at)numerixtechnology(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Scott Marlowe | 2006-07-07 18:49:41 | Re: Atomar SQL Statement |
| Previous Message | Stephan Szabo | 2006-07-07 18:07:10 | Re: Atomar SQL Statement |