Check whether two strs have at least one shared character.

Started by Emi Lualmost 19 years ago2 messagesgeneral
Jump to latest
#1Emi Lu
emilu@encs.concordia.ca

Hello,

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.

Thank you!

#2Albe Laurenz
all@adv.magwien.gv.at
In reply to: Emi Lu (#1)
Re: Check whether two strs have at least one shared character.

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