[GENERAL] Regexp + spaces PG 9.1

Поиск
Список
Период
Сортировка
От Patrick B
Тема [GENERAL] Regexp + spaces PG 9.1
Дата
Msg-id CAJNY3it9yjBgymM+s=KPfuC1Na28EMTf0oT+UgY8iepcD0+-QA@mail.gmail.com
обсуждение исходный текст
Ответы Re: [GENERAL] Regexp + spaces PG 9.1  ("David G. Johnston" <david.g.johnston@gmail.com>)
Список pgsql-general
Hi guys,

I've got a column which stores the file name on it, the column is character varying(255). I'm selecting that value in a CTE query; basically:


test1 AS (
SELECT 
regexp_matches(name, '((main|medium).name/\d+.\d+)') as filename,
from test1;
)

select
filename[1] 
from test1



As you can see on the example: 

  • if the file is a image (jpg), then it will have 2 variations (main|medium). 
  • If the file is a pdf, then it will only have 1 variation (main).
I basically need a regexp_matches expression that only gets me the file name, after the main.name/ for example.

On the example I gave there are 2 problems:

  1. I can only get the jpg file name
  2. I don't get only the file name but the rest as well, which is not what I need

How to do that?

Thanks!
Patrick




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

Предыдущее
От: Ludovic Vaugeois-Pepin
Дата:
Сообщение: Re: [GENERAL] pg_basebackup error: replication slot"pg_basebackup_2194" already exists
Следующее
От: "David G. Johnston"
Дата:
Сообщение: Re: [GENERAL] Regexp + spaces PG 9.1