reg expressions
Posted in 2000
Topics: Connectivity: ESQL/C, 4GL & Embedded SQL
How does informix treat regular expresions in a SELECT query. Something
like this:
SELECT * FROM friend WHERE firstname `^S`
just like PostgreSQL does???
"And I'm happy, because you make me feel good, about me." - Melvin Udall
-----------------------------------------------------------------
Mart'n Marqu's email: martin@math.unl.edu.ar
Santa Fe - Argentina http://math.unl.edu.ar/~martin/
Administrador de sistemas en math.unl.edu.ar
-----------------------------------------------------------------
"Martin A. Marques" wrote:
> How does informix treat regular expresions in a SELECT query. Something
> like this:
>
> SELECT * FROM friend WHERE firstname `^S`>
> just like PostgreSQL does???
That one gets treated as a syntax error (invalid character, because a
back quote cannot be part of a statement). Informix doesn't have real
regular expressions. Your best hopes are (1) ANSI/ISO "LIKE", which is
pretty damn feeble, (2) Informix "MATCHES", which is marginally better,
or (3) a data blade of some sort.
--
Yours,
Jonathan Leffler (Jonathan.Leffler@Informix.com) #include <disclaimer.h>
Guardian of DBD::Informix v1.00.PC1 -- http://www.perl.com/CPAN
"I don't suffer from insanity; I enjoy every minute of it!"
"Martin A. Marques" wrote:
>
> How does informix treat regular expresions in a SELECT query. Something
> like this:
>
> SELECT * FROM friend WHERE firstname `^S`>
> just like PostgreSQL does???
No. You can use a limited subset of UNIX style regular expressions using
the MATCHES keyword or you can use ANSI style regular expressions (only
wildcards are _ (match one char) and % (match any number of characters)
using the LIKE keyword. The expression you used as an example would be:
SELECT * FROM friend WHERE firstname MATCHES "S*";
-or-
SELECT * FROM friend WHERE firstname LIKE "S%";
Read the Guide to SQL Reference for details on the range of expressions
accepted by MATCHES. LIKE is limited to what is described here but is
ANSI SQL compliant.
Art S. Kagel