From: | Michael Moore <michaeljmoore(at)gmail(dot)com> |
---|---|
To: | Christopher Molnar <cmolnar(at)ourworldservices(dot)com> |
Cc: | postgres list <pgsql-sql(at)postgresql(dot)org> |
Subject: | Re: Regexp_replace question/assistance needed |
Date: | 2015-12-09 23:04:08 |
Message-ID: | CACpWLjNg7FAM5RB5dUGfuMwpNdktFjSu6cm==D56marRh=Dj3A@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
select
overlay ('http://test.com/test/testfile.php' placing '&file=' from
length('http://test.com/test/testfile.php')- position('/' in reverse('
http://test.com/test/testfile.php')) +1
for 1)
of course you would use a variable instead of a string literal
On Wed, Dec 9, 2015 at 1:59 PM, Christopher Molnar <
cmolnar(at)ourworldservices(dot)com> wrote:
> Hello,
>
> I am running into a problem and need some pointers on regexp_replace - I
> can't seem to find an answer in any of the online resources.
>
> I have a string (like 40,000 with different length and number of
> components) of them in a field named "externalurl". I need to replace the
> final "/" of the string with "&file=" while preserving the filename and
> extension following the "/".
>
> The closest I can get is:
>
> regexp_replace('http://test.com/test/testfile.php','/[^/]*$','&file=')
>
> however this looses the file name and returns:
>
> http://test.com/test&file=
>
> What I am looking for is:
>
> http://test.com/test&file=testfile.php
>
> as a result.
>
> Would anyone here point me in the right direction?
>
> Thanks!
> -Chris
>
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2015-12-10 00:51:03 | Re: CVS to In_list without dynamic SQL, how? |
Previous Message | Michael Moore | 2015-12-09 22:28:14 | Re: CVS to In_list without dynamic SQL, how? |