pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Herouth Maoz <herouth@oumail.openu.ac.il>
To: Richi Plana <richip@mozcom.com>
Cc: pgsql-sql@postgreSQL.org
Subject: Re: [GENERAL] Determining if "in a text set"
Date: Mon, 29 Mar 1999 12:34:14 +0200
Message-ID: <l03110702b32503ceda99@[147.233.148.145]> (raw)
In-Reply-To: <Pine.LNX.4.04.9903290235290.5417-100000@jaguar.mozcom.com>
References: <l0311070cb3240c3166d7@[147.233.148.142]>

At 20:56 +0200 on 28/03/1999, Richi Plana wrote:


>
> 1) I'm not sure the regex thing is ANSI SQL and would port to other SQL
> systems easilly

That's true. ANSI only has LIKE, but it's oh-so-limited.

> 2) Isn't there a way to do [^{ws}](word)[{ws}$], where [^{ws}] means
> either the start or a whitespace and [{ws}$] means either a whitespace or
> EOL?

Hehe... Actually, there is. This is what I came up with:

   SELECT * FROM {class}
   WHERE '{phrase}' ~ (
       '(^|[[:space:]])' || ( rtrim( FieldN ) || '([[:space:]]|$)' )
   );

It seems a bit complicated. The [[:space:]] combination is the set of all
whitespace characters. Like perl's \s, but locale-sensitive.

The combination '(^|[[:space:]])' uses the regexp alternatives syntax. This
means "Either the beginning of the phrase (^) or a space character". The
combination '([[:space:]]|$)' is, along the same lines, "either a space
character or the end of the phrase".

All the rest of the mess are concatenation operators, and the parentheses
required for their precedence and associativity.

> 3) When I try the concat strings operator (||), I get the following psql
> error:

Yes, you are right about the precedence (I don't know why I didn't
encounter it yesterday). One must also remember that the || operator is
also non-associative (no real reason for it - it's a minor bug), so you
have to put parentheses around it if you concat more than two strings.

Herouth

--
Herouth Maoz, Internet developer.
Open University of Israel - Telem project
http://telem.openu.ac.il/~herutma





view thread (7+ messages)

Message-ID: <l03110702b32503ceda99@[147.233.148.145]>
Permalink:  ../l03110702b32503ceda99@%5B147.233.148.145%5D/
Also on:    postgresql.org/message-id/l03110702b32503ceda99@[147.233.148.145]

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-sql@postgresql.org
  Cc: herouth@oumail.openu.ac.il, richip@mozcom.com
  Subject: Re: [GENERAL] Determining if "in a text set"
  In-Reply-To: <l03110702b32503ceda99@[147.233.148.145]>
  References: <l0311070cb3240c3166d7@[147.233.148.142]> <l03110702b32503ceda99@[147.233.148.145]>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox