Re: SELECT substring with regex

Поиск
Список
Период
Сортировка
От Richard Broersma Jr
Тема Re: SELECT substring with regex
Дата
Msg-id 20060707213301.36130.qmail@web31803.mail.mud.yahoo.com
обсуждение исходный текст
Ответ на Re: SELECT substring with regex  (T E Schmitz <mailreg@numerixtechnology.de>)
Список pgsql-sql
> valid entries would be:
> "28mm F2.8" (prime lens)
> "30-70mm F4" (zoom lens)
> "30-70mm F2.8" (zoom lens)
> "30-100mm F4.5-5.6" (zoom lens with variable speed)
> 
> 
> In the WHERE clause I have specified all those NAMEs, which follow that
> pattern but have some gubbins appended:
> 
> WHERE NAME ~
> '^((\\d+(-\\d+)?)mm F((\\d+(\.\\d+)?)+(\.(\\d+(\.\\d+)?)+)?))\\D+$'
> 
> 
> which gives me a listing of those candidates that need to be amended -
> manually or otherwise.
> 
> Next, I wanted to produce a result which splits NAME into what it should
> be (BASE) and attributes (SUFFIX). Maybe I can generate some SQL from
> that to tidy up the data.

would this give you the results you want?  It admit that it doesn't look to elegant.

name:
substr(your_string, 0, strpos(your_string, ' ')+1)

suffix:
substr(your_string, length(your_string)-strpos(your_string, ' '), length(your_string))

Regards,

Richard Broersma Jr.


В списке pgsql-sql по дате отправления:

Предыдущее
От: Oisin Glynn
Дата:
Сообщение: Re: Help with performance and explain.
Следующее
От: "Aaron Bono"
Дата:
Сообщение: Re: SELECT substring with regex