Re: Regexp_replace question / help needed

Поиск
Список
Период
Сортировка
От Jerry Sievers
Тема Re: Regexp_replace question / help needed
Дата
Msg-id 86oadz5jny.fsf@jerry.enova.com
обсуждение исходный текст
Ответ на Regexp_replace question / help needed  (Christopher Molnar <cmolnar@ourworldservices.com>)
Ответы Re: Regexp_replace question / help needed  (Christopher Molnar <cmolnar@ourworldservices.com>)
Список pgsql-general
Christopher Molnar <cmolnar@ourworldservices.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
onlineresources. 
>
> I have a string (like 40,000 with different length and number of components) of them in a field named "externalurl".
Ineed 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.consulting@comcast.net
p: 312.241.7800


В списке pgsql-general по дате отправления:

Предыдущее
От: Nicolas Paris
Дата:
Сообщение: Re: Regexp_replace question / help needed
Следующее
От: Christopher Molnar
Дата:
Сообщение: Re: Regexp_replace question / help needed