Re: Regexp_replace question/assistance needed - Mailing list pgsql-sql

From Michael Moore
Subject Re: Regexp_replace question/assistance needed
Date
Msg-id CACpWLjNg7FAM5RB5dUGfuMwpNdktFjSu6cm==D56marRh=Dj3A@mail.gmail.com
Whole thread Raw
In response to Regexp_replace question/assistance needed  (Christopher Molnar <cmolnar@ourworldservices.com>)
List pgsql-sql
select 
overlay ('http://test.com/test/testfile.php' placing '&file=' from
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@ourworldservices.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:


What I am looking for is:


as a result.

Would anyone here point me in the right direction?

Thanks!
-Chris

pgsql-sql by date:

Previous
From: Michael Moore
Date:
Subject: Re: CVS to In_list without dynamic SQL, how?
Next
From: "David G. Johnston"
Date:
Subject: Re: CVS to In_list without dynamic SQL, how?