in reply to postgres reg expression quoting

See Perl and PostgreSQL regex and particularly Re^2: Perl and PostgreSQL regex.


Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

Replies are listed 'Best First'.
Re^2: postgres reg expression quoting
by zdzieblo (Acolyte) on Apr 01, 2009 at 14:00 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 smells like a solution, quotemeta will add '\' to all non word characters and then during execution that '\' will get quoted to make it '\\' so postgress is happy

      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.

        of course there is.. what about the placeholder '?' ;-)