Skip site navigation (1) Skip section navigation (2)

Re: how to test string against regular expression contained in postgresql database field?

From: joe(at)tsolucio(dot)com (Joe Bordes)
To: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to test string against regular expression contained in postgresql database field?
Date: 2004-03-25 18:48:10
Message-ID: 9a0f19e3.0403251048.3b7bdbde@posting.google.com (view raw or flat)
Thread:
Lists: pgsql-novice
CoL <col(at)mportal(dot)hu> wrote in message news:<c3s060$1k0m$1(at)news(dot)hub(dot)org>...
> 
> create a function for that.
> 
> create or replace function osregexp(varchar,varchar) returns boolean as 
> ' select $1 ~ $2; 'language sql immutable;
> 
> SELECT osregexp('windows9x','win.*9x');
>   osregexp
> ----------
>   t
> 
> C.

Hi,

First thanks for answering.

This gives me the same error. I have created the function as you say
and it works when called directly with strings (as above) but not when
called with a table field.

select os_name from table where osregexp('windows9x',os_regexp);
ERROR: invalid regular expression: empty expression or subexpression

I even tried createing the function with STABLE and VOLATILE but I get
the same error

Joe.

In response to

Responses

pgsql-novice by date

Next:From: David P. LurieDate: 2004-03-25 23:44:15
Subject: Re: configure script failure with SCO 5.0.7
Previous:From: Tom LaneDate: 2004-03-25 16:17:29
Subject: Re: loop Through Query Results : Record

Privacy Policy | About PostgreSQL
Copyright © 1996-2014 The PostgreSQL Global Development Group