zdzieblo has asked for the wisdom of the Perl Monks concerning the following question:

hi,

any tips how to quote regular expression characters in queries like this:

my $sql = "SELECT a FROM table WHERE (a ~* (E\'.*\' || ?))";

update, I mean quoting them in the place holder of course ;-)

thanks

Replies are listed 'Best First'.
Re: postgres reg expression quoting
by moritz (Cardinal) on Apr 01, 2009 at 13:21 UTC
Re: postgres reg expression quoting
by BrowserUk (Patriarch) on Apr 01, 2009 at 13:27 UTC

      none of the above answers my question. if user enters '[' for their search query for example I get "ERROR: invalid regular expression: brackets [] not balanced"

      what I need is a double backlash before every unsafe character

        That's odd. There's nothing variable in what you presented, so how can any of it be from the user?

        Please don't post one piece of code and ask about another.