regexp_replace question/suggestions needed

From: Christopher Molnar <cmolnar65(at)gmail(dot)com>
To: pgsql-sql(at)postgresql(dot)org
Subject: regexp_replace question/suggestions needed
Date: 2015-12-09 21:57:35
Message-ID: CACU0s5XE64_LEHNPr=J_TMY7AZdbmPamCu-zdmpgCWev+WcypQ@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

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

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Corey Huinker 2015-12-09 21:57:39 Re: CVS to In_list without dynamic SQL, how?
Previous Message Michael Moore 2015-12-09 21:30:50 Re: CVS to In_list without dynamic SQL, how?