From: | Patrick B <patrickbakerbr(at)gmail(dot)com> |
---|---|
To: | pgsql-general <pgsql-general(at)postgresql(dot)org> |
Subject: | Regexp + spaces PG 9.1 |
Date: | 2017-05-31 04:17:03 |
Message-ID: | CAJNY3it9yjBgymM+s=KPfuC1Na28EMTf0oT+UgY8iepcD0+-QA@mail.gmail.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | 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
Example here: http://sqlfiddle.com/#!15/5f4f0/4
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
From | Date | Subject | |
---|---|---|---|
Next Message | David G. Johnston | 2017-05-31 04:34:00 | Re: Regexp + spaces PG 9.1 |
Previous Message | Ludovic Vaugeois-Pepin | 2017-05-30 22:20:22 | Re: pg_basebackup error: replication slot "pg_basebackup_2194" already exists |