Re: Escaping regexp special characters in field value

From: "David Johnston" <polobo(at)yahoo(dot)com>
To: "'Allan Kamau'" <kamauallan(at)gmail(dot)com>, "'Postgres General Postgres General'" <pgsql-general(at)postgresql(dot)org>
Subject: Re: Escaping regexp special characters in field value
Date: 2012-11-21 13:42:53
Message-ID: 023601cdc7ee$1b9277a0$52b766e0$@yahoo.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

ILIKE is probably better - without an escape:

WHERE field1 ILIKE field2 ESCAPE ''

You could also try:

WHERE upper(field1) = upper(field2)

David J.

From: pgsql-general-owner(at)postgresql(dot)org
[mailto:pgsql-general-owner(at)postgresql(dot)org] On Behalf Of Allan Kamau
Sent: Wednesday, November 21, 2012 4:39 AM
To: Postgres General Postgres General
Subject: [GENERAL] Escaping regexp special characters in field value

I do have a field for which I want to perform a join with some other field
in another table using case without case sensitivity perhaps using ~*.

One of this fields may contain + characters or unbalanced parenthesis. Is
there a way or some function that may mask out the regexp awareness of any
of these characters if they appear the field values.

Should I need to write a function to escape each of these characters by
placing a "\" character before it?

Allan.

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Ryan Kelly 2012-11-21 13:45:26 Re: output inserted
Previous Message Peter Kroon 2012-11-21 13:41:24 output inserted