Re: [GENERAL] Determining if "in a text set"

From: Herouth Maoz <herouth(at)oumail(dot)openu(dot)ac(dot)il>
To: Richi Plana <richip(at)mozcom(dot)com>
Cc: pgsql-sql(at)postgreSQL(dot)org
Subject: Re: [GENERAL] Determining if "in a text set"
Date: 1999-03-29 10:34:14
Message-ID: l03110702b32503ceda99@[147.233.148.145]
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general pgsql-sql

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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Rick Dearman 1999-03-29 10:51:37 Returning an integer from a date
Previous Message Pavel 1999-03-29 05:27:41 unsubscribe

Browse pgsql-sql by date

  From Date Subject
Next Message Eduardo Noeda 1999-03-29 10:49:19 IIF..
Previous Message Francois TETE 1999-03-29 08:42:05 Inheritance and update