| From: | T E Schmitz <mailreg(at)numerixtechnology(dot)de> |
|---|---|
| To: | Rodrigo De Leon <rdeleonp(at)gmail(dot)com> |
| Cc: | pgsql-sql(at)postgresql(dot)org |
| Subject: | Re: SELECT substring with regex |
| Date: | 2006-07-08 09:40:08 |
| Message-ID: | 44AF7D78.2050007@numerixtechnology.de |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-sql |
Rodrigo De Leon wrote:
> On 7/7/06, T E Schmitz <mailreg(at)numerixtechnology(dot)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
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Anthony Kinyage | 2006-07-08 10:35:03 | Re: table joining duplicate records |
| Previous Message | onin | 2006-07-08 09:02:04 | table joining duplicate records |