[GENERAL] Regexp + spaces PG 9.1 - Mailing list pgsql-general

From Patrick B
Subject [GENERAL] Regexp + spaces PG 9.1
Date
Msg-id CAJNY3it9yjBgymM+s=KPfuC1Na28EMTf0oT+UgY8iepcD0+-QA@mail.gmail.com
Whole thread Raw
Responses Re: [GENERAL] Regexp + spaces PG 9.1
List 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 by date:

Previous
From: Ludovic Vaugeois-Pepin
Date:
Subject: Re: [GENERAL] pg_basebackup error: replication slot"pg_basebackup_2194" already exists
Next
From: "David G. Johnston"
Date:
Subject: Re: [GENERAL] Regexp + spaces PG 9.1