From: | John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com> |
---|---|
To: | pgsql-general(at)postgresql(dot)org |
Subject: | Fwd: String reverse funtion? |
Date: | 2013-10-11 13:29:24 |
Message-ID: | CAAJSdji7oajQpYmxvbD40uTtHLLeCLaz83XaDqcQSQRgKKQYng@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
Forgot to reply to list. Sorry. Perhaps somebody here knows of an
"array_reverse" type function.
---------- Forwarded message ----------
From: John McKown <john(dot)archie(dot)mckown(at)gmail(dot)com>
Date: Fri, Oct 11, 2013 at 7:53 AM
Subject: Re: [GENERAL] String reverse funtion?
To: ginkgo36 <ginkgo56(at)gmail(dot)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(at)gmail(dot)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(at)postgresql(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | Jesse Long | 2013-10-11 13:32:21 | Re: Incorrect index being used |
Previous Message | Wolfgang Keller | 2013-10-11 12:47:15 | Re: Forms for entering data into postgresql |