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-29 16:42:46
Message-ID: 9a0f19e3.0403290842.5a97f5f3@posting.google.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-novice

tgl(at)sss(dot)pgh(dot)pa(dot)us (Tom Lane) wrote in message news:<26388(dot)1080329607(at)sss(dot)pgh(dot)pa(dot)us>...
> 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
>
> ---------------------------(end of broadcast)---------------------------
> TIP 1: subscribe and unsubscribe commands go to majordomo(at)postgresql(dot)org

Thank you very much for your answer. You were right, I had an empty
field in one of my rows.

It was my fault. I should have stopped and thought before jumping to
conclusions :-)

Regards, Joe.

In response to

Browse pgsql-novice by date

  From Date Subject
Next Message Josh Berkus 2004-03-29 21:46:05 Re: dynamic interval in plpgsql
Previous Message Tom Lane 2004-03-29 15:42:06 Re: problem on psql command