| From: | Christopher Molnar <cmolnar(at)ourworldservices(dot)com> |
|---|---|
| To: | |
| Cc: | pgsql-general(at)postgresql(dot)org |
| Subject: | Re: Regexp_replace question / help needed |
| Date: | 2015-12-09 23:02:19 |
| Message-ID: | CACU0s5UXQhArF2Nfy6dQCWGmoY8K0ri+x-NZxa6TRO+OE2bOrA@mail.gmail.com |
| Views: | Whole Thread | Raw Message | Download mbox | Resend email |
| Thread: | |
| Lists: | pgsql-general |
Thank you both. Problem solved - worked perfectly.
On Wed, Dec 9, 2015 at 5:41 PM, Jerry Sievers <gsievers19(at)comcast(dot)net>
wrote:
> Christopher Molnar <cmolnar(at)ourworldservices(dot)com> writes:
>
> > 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?
>
>
> > select regexp_replace('http://foo/wow/blah/zzz.php', '/([^/]*)$',
> '&file=\1');
> regexp_replace
> ----------------------------------
> http://foo/wow/blah&file=zzz.php
> (1 row)
>
>
> >
> > Thanks!
> > -Chris
> >
>
> --
> Jerry Sievers
> Postgres DBA/Development Consulting
> e: postgres(dot)consulting(at)comcast(dot)net
> p: 312.241.7800
>
| From | Date | Subject | |
|---|---|---|---|
| Next Message | Edson Richter | 2015-12-09 23:13:57 | Overhead changing varchar(2000) to text |
| Previous Message | Jerry Sievers | 2015-12-09 22:41:53 | Re: Regexp_replace question / help needed |