Hey David,
I guess, that you should escape, like this
dmitigr=> SELECT regexp_replace('di_ma%', '(%|_)', E'\\\\\\1', 'g');
regexp_replace
----------------
di\_ma\%
2010/11/23 David Sheldon <[email protected]>
> If I have a string, and I want to search for everything that starts with
> that string then I could do:
>
> SELECT * FROM users WHERE name LIKE string || '%';
>
> Now, if string contains \, _ or % then it won't do what I expect.
>
> Is there a built-in function that I can call to escape the string so that
> it isn't special for LIKE, or is it a case of regexing and putting a \
> before each \, _ or %?
>
> David
>
> --
> Sent via pgsql-general mailing list ([email protected])
> To make changes to your subscription:
> http://www.postgresql.org/mailpref/pgsql-general
>
--
// Dmitriy.