Search Postgresql Archives

Re: postgres function

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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


--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general



[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux