Re: Regular expression. How to disable ALL - Mailing list pgsql-general

From Scott Marlowe
Subject Re: Regular expression. How to disable ALL
Date
Msg-id 1114019411.20921.586.camel@state.g2switchworks.com
Whole thread Raw
In response to Re: Regular expression. How to disable ALL meta-character  (David Gagnon <dgagnon@siunik.com>)
Responses Re: Regular expression. How to disable ALL meta-character
List pgsql-general
On Wed, 2005-04-20 at 12:36, David Gagnon wrote:
> Michael Fuhr wrote:
>
> >On Wed, Apr 20, 2005 at 11:28:28AM -0400, David Gagnon wrote:
> >
> >
> >>I have a web interface with offers a search field.  This search field
> >>will look for the string X in 12 different columns.  If the string is
> >>found anywhere I return the row.
> >>
> >>The problem is that the user is eable to put spacial character like : [*
> >>This create invalid regular expression and make my sql crash.
> >>ICNUM~* #descriptionOrKeyword#
> >>
> >>Is there a way to disable all meta-character.
> >>
> >>
> >
> >Why are you doing a regular expression search if you don't want to
> >allow regular expressions?
> >
> >
> >
> Maybe there is a simple way to to this but I want find string X in
> different column.  The search must not be case sensitive.
>
> So that searching "aBc" in  "abcDef" return true.  I don't want
> META-CHaracter.  Or at least I don't want meta-character to cause errors
> (i.e.: No
>
> ERROR:  invalid regular expression: brackets [] not balanced.

I would generally scrub the input before it go to postgresql.  Basically
do a simple string_replace type function that replaces anything that
ISN'T alphanum with nothing.

pgsql-general by date:

Previous
From: David Gagnon
Date:
Subject: Re: Regular expression. How to disable ALL meta-character
Next
From: David Gagnon
Date:
Subject: Re: Regular expression. How to disable ALL meta-character