Received: from dell-laptop01.officenet.no (dell-laptop01.officenet.no [193.212.174.122]) by postgresql.org (Postfix) with ESMTP id 0D6AF475BA9 for ; Tue, 9 Apr 2002 05:53:42 -0400 (EDT) Received: by dell-laptop01.officenet.no (Postfix, from userid 502) id A9FF668F52; Tue, 9 Apr 2002 11:53:30 +0200 (CEST) Content-Type: text/plain; charset="iso-8859-1" From: Andreas Joseph Krogh Organization: OfficeNet AS To: "'pgsql-sql@postgresql.org'" Subject: Re: Scadinavian characters in regular expressions Date: Tue, 9 Apr 2002 11:53:29 +0200 X-Mailer: KMail [version 1.4] References: <910513A5A944D5118BE900C04F67CB5A1F82C5@MAIL> In-Reply-To: <910513A5A944D5118BE900C04F67CB5A1F82C5@MAIL> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Message-Id: <200204091153.29935.andreak@officenet.no> X-Archive-Number: 200204/92 X-Sequence-Number: 7357 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 two words (beg= in > with one or more characters not being spaces followed by a space followed > by one or more characters not being spaces). > But when scandinavian characters are included it returns 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 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 I just tried the following which returned false as expected: andreak=3D# SELECT 'one=E5 two three' ~ '^[^\s]+[\s][^\s]+$'; ?column? ---------- f (1 row) andreak=3D# select version(); version ----------------------------------------------------------- PostgreSQL 7.2 on i686-pc-linux-gnu, compiled by GCC 2.96 (1 row) NOTE: I replaced your [^ ] with the properly formated pattarn for whitespac= e:=20 [^\s] --=20 Andreas Joseph Krogh (Senior Software Developer) A hen is an egg's way of making another egg.