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
--
Sent via pgsql-general mailing list (pgsql-general@xxxxxxxxxxxxxx)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-general