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

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


pgsql-sql by date:

Previous
From: onin
Date:
Subject: table joining duplicate records
Next
From: Anthony Kinyage
Date:
Subject: Re: table joining duplicate records