Обсуждение: INSTR() like function?
In mySQL there is an INSTR(arg1,arg2) function that takes and looks for any
of the characters in arg1 and matches them against arg2
IE are the characters A or B or C or D in the string "dogma" would be
INSTR('ABCD','dogma');
Anyone help me to produce this sort of logic in an PSQL select statement?
PostgreSQL 7.0.2 and 6.5 are present here, solution for 7 series preferable,
and if the answer is to make a stored procedure then that's OK, I would
think that there is a way to do it already though.
Michael
"Michael Loftis" <taos@activesw.com> writes:
> IE are the characters A or B or C or D in the string "dogma" would be
> INSTR('ABCD','dogma');
See the regular-expression match operators (~ and ~*). The above would
be
select 'dogma'::text ~* '[ABCD]'::text;
assuming you meant you wanted case-insensitive match.
regards, tom lane
Thanks much! I never even realised pg had regex built in.
-----Original Message-----
From: Tom Lane [mailto:tgl@sss.pgh.pa.us]
Sent: Thursday, October 12, 2000 2:50 PM
To: Michael Loftis
Cc: pgsql-general@postgresql.org
Subject: Re: [GENERAL] INSTR() like function?
"Michael Loftis" <taos@activesw.com> writes:
> IE are the characters A or B or C or D in the string "dogma" would be
> INSTR('ABCD','dogma');
See the regular-expression match operators (~ and ~*). The above would
be
select 'dogma'::text ~* '[ABCD]'::text;
assuming you meant you wanted case-insensitive match.
regards, tom lane