Re: Check whether two strs have at least one shared character.

From: "Albe Laurenz" <all(at)adv(dot)magwien(dot)gv(dot)at>
To: <emilu(at)encs(dot)concordia(dot)ca>, <pgsql-general(at)postgresql(dot)org>
Subject: Re: Check whether two strs have at least one shared character.
Date: 2007-07-03 14:50:15
Message-ID: AFCCBB403D7E7A4581E48F20AF3E5DB203AA7921@EXADV1.host.magwien.gv.at
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

Emi Lu wrote:
> Is there a simple way/command/function to check whether two
> strings have at least one overlap character please?
>
> For example,
>
> str1: 05baaa
> str2: ooboo
>
> Query: select str1 ??? str2 ;
>
> Result: true
>
> Because b is in both str1 and str2.

SELECT str1 ~ ( '[' || str2 || ']');

See
http://www.postgresql.org/docs/current/static/functions-matching.html#FU
NCTIONS-POSIX-REGEXP

Yours,
Laurenz Albe

In response to

Browse pgsql-general by date

  From Date Subject
Next Message Tom Lane 2007-07-03 15:00:45 Re: recovery_target_time ignored or recovery always recovers to end of WAL
Previous Message Emi Lu 2007-07-03 13:48:02 Check whether two strs have at least one shared character.