Re: Regular Expression for 'and' instead of 'or'

From: Medi Montaseri <medi(at)cybershell(dot)com>
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: Regular Expression for 'and' instead of 'or'
Date: 2002-02-22 21:26:44
Message-ID: 3C76B794.445B2D71@cybershell.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

Based on generic rules of Regular Expression, the default is a AND.
For example

RE-1RE-2RE-3 is really (RE-1) and (RE-2) and (RE-3). However Regular
Expression
also provides the "Alternation Metachar" to change it from a default AND
to a OR.

The problem however is if you have target-1 junk target-2 junk junk
target-3
Then the simple (target-1target-2target-3) would not work, as you are
implying
they are following each other. So the fix could be

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

Effectively you are creating a composite expression consisting of three
sub-expression.

"Samuel J. Sutjiono" wrote:

> This expression matches the word socks or shoes or nike in product
> categorywhere 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' ? Thanks,Sam

--
-------------------------------------------------------------------------
Medi Montaseri medi(at)CyberShell(dot)com
Unix Distributed Systems Engineer HTTP://www.CyberShell.com
CyberShell Engineering
-------------------------------------------------------------------------

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Martijn van Oosterhout 2002-02-22 21:43:28 Re: Speed comparison to Oracle. Why was this query slower on pgsql?
Previous Message Kenneth Gangstoe 2002-02-22 21:12:22 game db

Browse pgsql-sql by date

  From Date Subject
Next Message Hunter, Ray 2002-02-22 21:53:46 Bench Test
Previous Message Peter Eisentraut 2002-02-22 20:45:07 Re: [SQL] Regular Expression for 'and' instead of 'or'