Validating user-input to be inserted in regular expressions - Mailing list pgsql-general

From Vincenzo Ciancia
Subject Validating user-input to be inserted in regular expressions
Date
Msg-id ct328q$4ms$1@sea.gmane.org
Whole thread Raw
List pgsql-general
Hi all,

I would like to take user input, which should be interpreted literally, and
put it inside a regular expression, something like

select * from files where path ~ (USER_INPUT || '.*')

How should I escape the user input? I mean: I know that I must insert double
backslashes before special characters (in the sense of regular expressions)
but how to know what these special characters are? Should I find every
possible character in the documentation for regular expressions? Is there a
safer way?

Thanks

Vincenzo Ciancia

--
Please note that I do not read the e-mail address used in the from field but
I read vincenzo_ml at yahoo dot it
Attenzione: non leggo l'indirizzo di posta usato nel campo from, ma leggo
vincenzo_ml at yahoo dot it

pgsql-general by date:

Previous
From: Gregory Stark
Date:
Subject: Bug report in 7.4
Next
From: John DeSoi
Date:
Subject: Re: number of rown in a cursor.