From: | Michael Glaesemann <grzm(at)seespotcode(dot)net> |
---|---|
To: | shiguoying <shiguoying(at)yeah(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: i have a problem with judge some words contain chinese word! |
Date: | 2009-03-30 22:52:32 |
Message-ID: | 291BF5D7-D3FD-4F9D-9577-A6E433870EC4@seespotcode.net |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
On Mar 30, 2009, at 10:14 , shiguoying wrote:
>
> Hello:
> I have a problem with juding some words contain chinese word.
>
> I found that with oracle.but i can't find it in postgresql.
> oracle? has acsiistr and lengthb to deal with it.i wonna to know
> postgresql how to !
> ??? thx !
> from
> eagle
You can use regexp_replace to remove sets of charcters and then
compare lengths or even the strings themselves:
SELECT some_text, LENGTH(some_text), re, LENGTH(re), some_text = re as
str_eq, LENGTH(some_text) = LENGTH(re) AS len_eq
FROM (SELECT some_text, regexp_replace(some_text, $re$[^[:ascii:]]
$re$, '', 'g') as re
FROM (VALUES ('foo'), ('foo bar baz'), ('foo.bar,baz'), ('foo
案')) AS samples(some_text)) AS s;
some_text | length | re | length | str_eq | len_eq
-------------+--------+-------------+--------+--------+--------
foo | 3 | foo | 3 | t | t
foo bar baz | 11 | foo bar baz | 11 | t | t
foo.bar,baz | 11 | foo.bar,baz | 11 | t | t
foo案 | 4 | foo | 3 | f | f
(4 rows)
Michael Glaesemann
grzm seespotcode net
From | Date | Subject | |
---|---|---|---|
Next Message | jc_mich | 2009-03-30 23:55:19 | PL/PGSQL arithmetic errors |
Previous Message | Vyacheslav Kalinin | 2009-03-30 22:25:16 | Re: Read a CLOB data from an Oracle table and INSERT it into a BYTEA column in Postgres using jdbc? |