Received: from mail.netpointers.com (unknown [212.130.10.187]) by postgresql.org (Postfix) with ESMTP id 7FF074750F5 for ; Tue, 9 Apr 2002 07:27:53 -0400 (EDT) Received: by MAIL with Internet Mail Service (5.5.2650.21) id ; Tue, 9 Apr 2002 13:28:39 +0200 Message-ID: <910513A5A944D5118BE900C04F67CB5A1F82C6@MAIL> From: =?iso-8859-1?Q?S=F8ren_Vainio?= To: 'Andreas Joseph Krogh' , "'pgsql-sql@postgresql.org'" Subject: Re: Scadinavian characters in regular expressions Date: Tue, 9 Apr 2002 13:28:38 +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/93 X-Sequence-Number: 7358 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 expect TRUE??? (I am using PostgreSQL 7.1.3) > -----Oprindelig meddelelse----- > Fra: pgsql-sql-owner@postgresql.org > [mailto:pgsql-sql-owner@postgresql.org]P=E5 vegne af Andreas=20 > Joseph Krogh > Sendt: 9. april 2002 11:53 > Til: 'pgsql-sql@postgresql.org' > Emne: Re: [SQL] Scadinavian characters in regular expressions >=20 >=20 > On Tuesday 09 April 2002 10:51, S=F8ren Vainio wrote: > > Can someone please explain the following? > > I am using a regular expression to find strings containing=20 > two words (begin > > with one or more characters not being spaces followed by a=20 > space followed > > by one or more characters not being spaces). > > But when scandinavian characters are included it returns=20 > different results > > depending on where the character is positioned. > > The first two-word example returns TRUE as expected. > > The second three-word example returns FALSE as expected. > > But when I let an =E5 (å å a-ring) traverse through=20 > the string it > > unexpectedly returns TRUE when the character is positioned as the > > second-last or last character in the two first words. > > > > SELECT 'one two' ~ '^[^ ]+[ ][^ ]+$'; returns TRUE > > SELECT 'one two three' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT '=E5one two three' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'o=E5ne two three' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'on=E5e two three' ~ '^[^ ]+[ ][^ ]+$'; returns TRUE > > SELECT 'one=E5 two three' ~ '^[^ ]+[ ][^ ]+$'; returns TRUE > > SELECT 'one =E5two three' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'one t=E5wo three' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'one tw=E5o three' ~ '^[^ ]+[ ][^ ]+$'; returns TRUE > > SELECT 'one two=E5 three' ~ '^[^ ]+[ ][^ ]+$'; returns TRUE > > SELECT 'one two =E5three' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'one two t=E5hree' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'one two th=E5ree' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'one two thr=E5ee' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'one two thre=E5e' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > SELECT 'one two three=E5' ~ '^[^ ]+[ ][^ ]+$'; returns FALSE > > > > Thank you for any response. > > > > S=F8ren Vainio, Denmark >=20 > I just tried the following which returned false as expected: > andreak=3D# SELECT 'one=E5 two three' ~ '^[^\s]+[\s][^\s]+$'; > ?column? > ---------- > f > (1 row) >=20 > andreak=3D# select version(); > version > ----------------------------------------------------------- > PostgreSQL 7.2 on i686-pc-linux-gnu, compiled by GCC 2.96 > (1 row) >=20 > NOTE: I replaced your [^ ] with the properly formated pattarn=20 > for whitespace:=20 > [^\s] >=20 > --=20 > Andreas Joseph Krogh (Senior Software Developer)=20 > > A hen is an egg's way of making another egg. >=20 > ---------------------------(end of=20 > broadcast)--------------------------- > TIP 3: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >=20