Re: [SQL] Regular Expression for 'and' instead of 'or'

From: Peter Eisentraut <peter_e(at)gmx(dot)net>
To: "Samuel J(dot) Sutjiono" <ssutjiono(at)wc-group(dot)com>
Cc: <pgsql-sql(at)postgresql(dot)org>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: [SQL] Regular Expression for 'and' instead of 'or'
Date: 2002-02-22 20:45:07
Message-ID: Pine.LNX.4.30.0202221543100.686-100000@peter.localdomain
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Samuel J. Sutjiono writes:

> 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 probably want something like

productdescr ~* 'socks' AND productdescr ~* 'shoes' AND productdescr ~* 'nike'

I don't think it's possible to do this for the general case with just a
regular expression.

--
Peter Eisentraut peter_e(at)gmx(dot)net

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2002-02-22 20:45:30 Re: Does iscachable work?
Previous Message Kenneth Gangstoe 2002-02-22 20:40:31 game db

Browse pgsql-sql by date

  From Date Subject
Next Message Medi Montaseri 2002-02-22 21:26:44 Re: Regular Expression for 'and' instead of 'or'
Previous Message Tom Lane 2002-02-22 20:20:39 Re: Regular Expression for 'and' instead of 'or'