Re: [GENERAL] Regular Expression for 'and' instead of 'or' - Mailing list pgsql-sql

From Fernando Schapachnik
Subject Re: [GENERAL] Regular Expression for 'and' instead of 'or'
Date
Msg-id 20020222151514.E2066@ns1.via-net-works.net.ar
Whole thread Raw
In response to Regular Expression for 'and' instead of 'or'  ("Samuel J. Sutjiono" <ssutjiono@wc-group.com>)
Responses Re: [GENERAL] Regular Expression for 'and' instead of 'or'  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-sql
En un mensaje anterior, Samuel J. Sutjiono escribió:
> This expression matches the word socks or shoes or nike in product category
> where productdescr ~* '(socks|shoes|nike)'
>
> Does anybody know what the expression should be  if I want to do 'and' of those key words instead of 'or' ?

You have to use something like:

'(socks.*shoes.*nike)|(socks.*nike.*shoes)|...'

where ... is every other possible combination. Not pretty, but that's
a limitation of finite automata (or regular expressions, which are
the same).

Regards.



Fernando P. Schapachnik
Gerente de tecnología de red
y sistemas de información
VIA NET.WORKS ARGENTINA S.A.
fschapachnik@vianetworks.com.ar
Tel.: (54-11) 4323-3381

pgsql-sql by date:

Previous
From: Oliver Elphick
Date:
Subject: Re: How does Index Scan get used
Next
From: "Samuel J. Sutjiono"
Date:
Subject: Re: [GENERAL] Regular Expression for 'and' instead of 'or'