Re: [GENERAL] Pattern Matching question - PG 9.6

Поиск
Список
Период
Сортировка
От matshyeq
Тема Re: [GENERAL] Pattern Matching question - PG 9.6
Дата
Msg-id CAONr5=upSCurkfr4fe8yXxSiatGumLq79pWe27bXpn8BAHJEpg@mail.gmail.com
обсуждение исходный текст
Ответ на Re: [GENERAL] Pattern Matching question - PG 9.6  (Patrick B <patrickbakerbr@gmail.com>)
Список pgsql-general
^/testfile/client/[0-9]+/attachment/([0-9]{1,14}/master/$|unassigned/)

Kind Regards 
~Maciek
On 15 May 2017 at 06:21, Patrick B <patrickbakerbr@gmail.com> wrote:


2017-05-15 16:10 GMT+12:00 David G. Johnston <david.g.johnston@gmail.com>:
On Sunday, May 14, 2017, Patrick B <patrickbakerbr@gmail.com> wrote:

5   /testfile/client/10/attachment/1000/master/   10

7   /testfile/client/10/attachment/unassigned/file/1001/master   10

8   /testfile/client/10/attachment/unassigned/file/1002/master   10

What am I doing wrong?


Without you explaining why 6 and 9 are invalid it's impossible to say how you should modify your regex to exclude them.  You may find positive and negative look-ahead useful though.

David J.


I thought I have already explained it. Here it goes again. Demo page is: http://dbfiddle.uk/?rdbms=postgres_9.6&fiddle=ea61e7e1859bdb7f297f853a9dc0e3d0


As you can see, there is a lot of variations for the same file_id (1000). File_id (1001/1002) is a new unassigned file, different from the others.

I wanna be able to get ONLY the 'master' variation ( /testfile/client/10/attachment/1000/master/ ) and the unassigned files variations [if any] (/testfile/client/10/attachment/unassigned/file/1001/master | /testfile/client/10/attachment/unassigned/file/1002/master).

So on the demo above, only id IN (5,9,10) are valid for me. The SELECT that I used as an example is not returning me ONLY the data I need, instead, it is returning (almost) everything.


To summarize: I wanna use a pattern matching the only returns these rows:

/testfile/client/10/attachment/1000/master/
/testfile/client/10/attachment/unassigned/file/1001/master
/testfile/client/10/attachment/unassigned/file/1002/master


What can I do to fix it?
Thanks
P.




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

Предыдущее
От: "David G. Johnston"
Дата:
Сообщение: Re: [GENERAL] Pattern Matching question - PG 9.6
Следующее
От: Andreas Joseph Krogh
Дата:
Сообщение: [GENERAL] How to include BIGINT-column in RUM-index sorted by timestamp