Re: Re: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)

From: Karsten Hilbert <Karsten(dot)Hilbert(at)gmx(dot)net>
To: pgsql-general(at)postgresql(dot)org
Subject: Re: Re: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)
Date: 2017-01-17 14:49:19
Message-ID: 20170117144919.vtgf462vtfmddo2v@hermes.hilbert.loc
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: 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

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Andrew Kerber 2017-01-17 15:20:36 Largepages in Windows
Previous Message Thomas Kellerer 2017-01-17 14:27:57 Re: Is it possible to specify an ESCAPE for a wildcard search using LIKE ANY (...)