regexp_replace question / help needed - Mailing list pgsql-general

From Christopher Molnar
Subject regexp_replace question / help needed
Date
Msg-id CACU0s5Uov201MEhvC=Vhk+1jBN-NPTfEiek0T1CvgGv7Wth7nw@mail.gmail.com
Whole thread Raw
Responses Re: regexp_replace question / help needed
List pgsql-general
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-general by date:

Previous
From: "David G. Johnston"
Date:
Subject: Re: Loggingt psql meta-commands
Next
From: Berend Tober
Date:
Subject: Re: Deletion Challenge