Received: from mail.netpointers.com (unknown [212.130.10.187]) by postgresql.org (Postfix) with ESMTP id D136B475C38 for ; Tue, 9 Apr 2002 10:21:57 -0400 (EDT) Received: by MAIL with Internet Mail Service (5.5.2650.21) id ; Tue, 9 Apr 2002 16:21:43 +0200 Message-ID: <910513A5A944D5118BE900C04F67CB5A1F82C7@MAIL> From: =?iso-8859-1?Q?S=F8ren_Vainio?= To: 'Tom Lane' Cc: "'pgsql-sql@postgresql.org'" Subject: Re: Scadinavian characters in regular expressions Date: Tue, 9 Apr 2002 16:21:43 +0200 MIME-Version: 1.0 X-Mailer: Internet Mail Service (5.5.2650.21) Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: quoted-printable X-Archive-Number: 200204/100 X-Sequence-Number: 7365 There is obviously a problem with the scecial characters. The query SELECT 'one=E5 two three' ~ '^[^ ]+[ ][^ ]+$'; produced FALSE on a database with ENCODING =3D 'LATIN1' and TRUE on a datab= ase with ENCODING =3D 'UNICODE'. Do you have a suggestion to how I can find the count of two-word strings with ENCODING =3D 'UNICODE'? Thank you S=F8ren Vainio > -----Oprindelig meddelelse----- > Fra: Tom Lane [mailto:tgl@sss.pgh.pa.us] > Sendt: 9. april 2002 15:34 > Til: S=F8ren Vainio > Cc: 'Andreas Joseph Krogh'; 'pgsql-sql@postgresql.org' > Emne: Re: [SQL] Scadinavian characters in regular expressions=20 >=20 >=20 > =3D?iso-8859-1?Q?S=3DF8ren_Vainio?=3D writes: > > Using \s does produce FALSE for SELECT 'one=E5 two three' ~ > > '^[^\s]+[\s][^\s]+$'; > > But it also produces FALSE for any two-word string ex: > > SELECT 'one two' ~ '^[^\s]+[\s][^\s]+$'; where I would=20 > expect TRUE??? > > (I am using PostgreSQL 7.1.3) >=20 > I do not believe that Postgres' regular expression engine=20 > recognizes \s > as meaning anything except "s". See > http://www.ca.postgresql.org/users-lounge/docs/7.2/postgres/fu nctions-matching.html In the above, it's even worse: the backslashes were eaten by the string-literal parser, so what arrived at the RE engine was just ^[^s]+[s][^s]+$ ... not likely to produce what you wanted. As for the original issue, I wonder whether you are storing the string as UTF-8 or Latin1 encoding. I have a suspicion that the =E5 (å å a-ring) is actually a multibyte sequence inside the database and for some reason Postgres isn't configured to recognize it as a single logical character. regards, tom lane