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

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

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: joe(at)tsolucio(dot)com (Joe Bordes)
Cc: pgsql-novice(at)postgresql(dot)org
Subject: Re: how to test string against regular expression contained in postgresql database field?
Date: 2004-03-26 19:33:27
Message-ID: 26388.1080329607@sss.pgh.pa.us (view raw or flat)
Thread:
Lists: pgsql-novice
joe(at)tsolucio(dot)com (Joe Bordes) writes:
> I have a table which contains a field with regular expressions. I want
> to test a given string against this field to obtain the resulting
> records but I am doing something wrong and cannot find out what.

> select os_name from table where 'windows9x' ~ os_regexp;
> ERROR: invalid regular expression: empty expression or subexpression.

Looks to me like there's at least one row in the table whose os_regexp
is wrong.  I'm not quite sure *why* it's wrong ... I tried a few
examples to see if I could duplicate that message, and I couldn't find
one.  But you want to look to the regexps themselves, the query is fine.

			regards, tom lane

In response to

Responses

pgsql-novice by date

Next:From: Stephan SzaboDate: 2004-03-26 19:40:02
Subject: Re: how to test string against regular expression contained
Previous:From: Tom LaneDate: 2004-03-26 19:19:49
Subject: Re: Extract Function

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