Re: postgres function

Поиск
Список
Период
Сортировка
От Jim Nasby
Тема Re: postgres function
Дата
Msg-id 56217800.8020108@BlueTreble.com
обсуждение исходный текст
Ответ на postgres function  (Ramesh T <rameshparnanditech@gmail.com>)
Список pgsql-general
On 10/14/15 8:38 AM, Ramesh T wrote:
> Hi All,
>            Do we have  function like  regexp_substr in postgres..?
>
> in oracle this function seach the - from 1 to 2 and return result,
> regexp_substr(PART_CATG_DESC,'[^-]+', 1, 2)

Use regexp_split_to_array(string text, pattern text [, flags text ]):

SELECT regexp_split_to_array('1-2-3-4-5', '-');
  regexp_split_to_array
-----------------------
  {1,2,3,4,5}

If you just want one part of the array:

SELECT (regexp_split_to_array('1-2-3-4-5', '-'))[2];
  regexp_split_to_array
-----------------------
  2

(Note the extra ()s)

If that's not what you need then as David suggested please provide a few
input values and what you expect as your *final* output. IE: tell us
what you're ultimately trying to do, instead of just asking about regexp
matching. There may be a much better way to do it in Postgres than
whatever you were doing in Oracle.
--
Jim Nasby, Data Architect, Blue Treble Consulting, Austin TX
Experts in Analytics, Data Architecture and PostgreSQL
Data in Trouble? Get it in Treble! http://BlueTreble.com


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

Предыдущее
От: Jim Nasby
Дата:
Сообщение: Re: converting in() clause into a with prefix?
Следующее
От: Karsten Hilbert
Дата:
Сообщение: Re: ID column naming convention