in reply to Re^2: postgres reg expression quoting
in thread postgres reg expression quoting

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.

Replies are listed 'Best First'.
Re^4: postgres reg expression quoting
by zdzieblo (Acolyte) on Apr 01, 2009 at 14:40 UTC
    of course there is.. what about the placeholder '?' ;-)

      My apologies. I didn't look at the expression closely enough and jumped to the wrong conclusion. I have a better understanding of it now.

      If you're expecting the user to provide text to match literally (as opposed to a regular expression pattern), then you need to convert the text into a regular expression pattern. In Perl, quotemeta would do. It will probably do for your database as well.

      my $input = '['; $sth->execute(quotemeta($input));
        after some testing it showed that this solution fails on unicode strings :/ unfortunately