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

From David Gagnon
Subject Re: Regular expression. How to disable ALL meta-character
Date
Msg-id 42669308.3040703@siunik.com
Whole thread Raw
In response to Datatypes in PL/PSQL functions with multiple arguments  (Benjamin Holmberg <benjamin.holmberg@gmail.com>)
Responses Re: Regular expression. How to disable ALL
Re: Regular expression. How to disable ALL meta-character
List pgsql-general
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.



Thanks for your help
/David








>>I found this in the manual .. but haven't found example :-(:
>>: ....with ***=, the rest of the RE is taken to be a literal string,
>>with all characters considered ordinary characters.
>>
>>
>
>Read again the entire sentence, especially the first few words:
>
>  If an RE begins with ***=, the rest of the RE is taken to be a
>  literal string, with all characters considered ordinary characters.
>
>Here are some examples:
>
>SELECT 'test string' ~ 'test[*';
>ERROR:  invalid regular expression: brackets [] not balanced
>
>SELECT 'test string' ~ '***=test[*';
> ?column?
>----------
> f
>(1 row)
>
>SELECT 'test[* string' ~ '***=test[*';
> ?column?
>----------
> t
>(1 row)
>
>
>


pgsql-general by date:

Previous
From: Scott Marlowe
Date:
Subject: Re: Filesystem options for storing pg_data
Next
From: Scott Marlowe
Date:
Subject: Re: Regular expression. How to disable ALL