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

Select with Regular Expressions

From: Peter Weinzierl <peter(dot)weinzierl(at)gmail(dot)com>
To: pgsql-novice(at)postgresql(dot)org
Subject: Select with Regular Expressions
Date: 2006-02-26 10:04:16
Message-ID: (view raw, whole thread or download thread mbox)
Lists: pgsql-novice

testing a program I ran into a glitch working with the ~* statement.
The problem is, that whenever I want to query something from the 
database with ~* containing brackets () or a question mark psql throws 
an exception.
So far I have tried to escape the sequence but then I ran into another 
problem. Psql didn't fetch the result I wanted it to fetch (the one with 
the brackets or question mark),
but one that was similiar to the one I wanted it to fetch.
Here's an example:
I want to fetch 'my (search) string' from the table

select bar from table where bar ~*' my (search) string';

This didn't work out so I tried:

select bar from table where bar~*'my \(search\) string';

But this only returned:

'my search string'

and not the wanted result 'my (search) string'.
The problem is, that I have to escape ... the string otherwise my 
program throws an exception.

The language is python.

Thanx in advance



pgsql-novice by date

Next:From: Tom AllisonDate: 2006-02-26 18:26:35
Subject: references versus foreign keys
Previous:From: Johnny lDate: 2006-02-26 01:31:20
Subject: exporting to DTD

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