Fwd: String reverse funtion?

Поиск
Список
Период
Сортировка
От John McKown
Тема Fwd: String reverse funtion?
Дата
Msg-id CAAJSdji7oajQpYmxvbD40uTtHLLeCLaz83XaDqcQSQRgKKQYng@mail.gmail.com
обсуждение исходный текст
Ответ на String reverse funtion?  (ginkgo36 <ginkgo56@gmail.com>)
Ответы Re: Fwd: String reverse funtion?  (ginkgo36 <ginkgo56@gmail.com>)
Список pgsql-general
Forgot to reply to list. Sorry. Perhaps somebody here knows of an "array_reverse" type function.

---------- Forwarded message ----------
From: John McKown <john.archie.mckown@gmail.com>
Date: Fri, Oct 11, 2013 at 7:53 AM
Subject: Re: [GENERAL] String reverse funtion?
To: ginkgo36 <ginkgo56@gmail.com>


I don't see one. Looks like you will need to write your own function. I got close with a kludge. But I cannot find a base function which will "reverse" the order of elements in an array. If there were such a one, which I will call "array_reverse" in the example, then you could do:

select array_to_string( array_reverse( regexp_split_to_array(string_delimited_with_semicolons,';') ),';');

This would split the string into an array, where each element is delimited with a semi-colon - regexp_split_to_array
Reverse the order of the array with the __missing__ array_reverse function.
Combine back into a string with array_to_string.

But, given the lack of "array_reverse" or something equivalent, I guess you need to "roll your own" function.



On Wed, Oct 9, 2013 at 10:59 AM, ginkgo36 <ginkgo56@gmail.com> wrote:
Hello everyone

I have to reverse a string like EA;BX;CA to CA;BX;EA. or EA,BX,CA to
CA,BX,EA

Is there any function to do this?

Thanks all!



--
View this message in context: http://postgresql.1045698.n5.nabble.com/String-reverse-funtion-tp5773871.html
Sent from the PostgreSQL - general mailing list archive at Nabble.com.


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



--
This is clearly another case of too many mad scientists, and not enough hunchbacks.

Maranatha! <><
John McKown



--
This is clearly another case of too many mad scientists, and not enough hunchbacks.

Maranatha! <><
John McKown

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

Предыдущее
От: "SUNDAY A. OLUTAYO"
Дата:
Сообщение: Re: Forms for entering data into postgresql‏
Следующее
От: Jesse Long
Дата:
Сообщение: Re: Incorrect index being used