Re: [GENERAL] Re: Is it possible to specify an ESCAPE for a wildcardsearch using LIKE ANY (...) - Mailing list pgsql-general

From Karsten Hilbert
Subject Re: [GENERAL] Re: Is it possible to specify an ESCAPE for a wildcardsearch using LIKE ANY (...)
Date
Msg-id 20170117144919.vtgf462vtfmddo2v@hermes.hilbert.loc
Whole thread Raw
In response to [GENERAL] Re: Is it possible to specify an ESCAPE for a wildcard search usingLIKE ANY (...)  (Thomas Kellerer <spam_eater@gmx.net>)
List pgsql-general
On Tue, Jan 17, 2017 at 03:27:57PM +0100, Thomas Kellerer wrote:

>> Do you need to have the _ NOT be recognized as a wildcard ?
>
> Yes, the underscore should NOT be a wildcard in this case.

Understood.

So, as Tom hinted at, your best bet might be to write a

    function escape_underscore_in_1dim_text_array(IN TEXT[], OUT TEXT[])
        ...

which takes an array and puts '\' in front of every '_' of
each member such that you can write

    ... like any (escape_underscore_in_1dim_text_array(your_array)) ...

Would that solve the problem ?

(this assume *no* underscore is to be a wildcard in user
provided input, not just some)

Karsten
--
GPG key ID E4071346 @ eu.pool.sks-keyservers.net
E167 67FD A291 2BEA 73BD  4537 78B9 A9F9 E407 1346


pgsql-general by date:

Previous
From: Thomas Kellerer
Date:
Subject: [GENERAL] Re: Is it possible to specify an ESCAPE for a wildcard search usingLIKE ANY (...)
Next
From: Andrew Kerber
Date:
Subject: [GENERAL] Largepages in Windows