Received: from malur.postgresql.org ([2a02:16a8:dc51::56]) by arkaria.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqJyG-0006Gf-8A for pgsql-general@arkaria.postgresql.org; Thu, 16 Aug 2018 15:13:56 +0000 Received: from localhost ([127.0.0.1] helo=malur.postgresql.org) by malur.postgresql.org with esmtp (Exim 4.89) (envelope-from ) id 1fqJyD-0000FP-G8 for pgsql-general@arkaria.postgresql.org; Thu, 16 Aug 2018 15:13:53 +0000 Received: from magus.postgresql.org ([2a02:c0:301:0:ffff::29]) by malur.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqJyD-0000FI-80 for pgsql-general@lists.postgresql.org; Thu, 16 Aug 2018 15:13:53 +0000 Received: from out1-smtp.messagingengine.com ([66.111.4.25]) by magus.postgresql.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_CBC_SHA384:256) (Exim 4.89) (envelope-from ) id 1fqJy4-0003l9-9n for pgsql-general@lists.postgresql.org; Thu, 16 Aug 2018 15:13:52 +0000 Received: from compute6.internal (compute6.nyi.internal [10.202.2.46]) by mailout.nyi.internal (Postfix) with ESMTP id 8C5C621F49; Thu, 16 Aug 2018 11:13:42 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Thu, 16 Aug 2018 11:13:42 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=aklaver.com; h= cc:content-transfer-encoding:content-type:date:from:in-reply-to :message-id:mime-version:references:subject:to:x-me-sender :x-me-sender:x-sasl-enc; s=fm3; bh=5LkQzsVLIQrtVxnE9xPoe2BPZUwse 0mQP331h1qYQJU=; b=IuaSHc92+IkvSSh9bmpsz99HYsBx80NsQ/nzp7UPW1k/F MMAbh/R+Uppq2NBnsnhocdL3FsfPOPH+KD4fAr22E0ZFHwBOUz5hF7G8GmoiyuOY xbj42d0Qt5puF4zLP/TOXmH4HIuq7FZqvT7bTrMf6SiPyTihREAxXxUjCwLKuX04 KoZnmm0r38/0PzuDKtbFf+6ewQD0uhnmQnAKjRUaWoGJxMpE2s2luQMvTlO/e8aO GTafgOAZYGn2IGDrA6ALltoAFJ0uRRwKFNsNFXcVWEKO67IIcQ4SdDmjgXBdXzhj tmRUsTItBK4Tj3xIlw5aW8RgfxV0swg+CVjeBAwVg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:content-transfer-encoding:content-type :date:from:in-reply-to:message-id:mime-version:references :subject:to:x-me-sender:x-me-sender:x-sasl-enc; s=fm3; bh=5LkQzs VLIQrtVxnE9xPoe2BPZUwse0mQP331h1qYQJU=; b=Dwyj5trfox98ueWGsDDYXX 1anoMwEsKyfjVPlfXrYMLvPYkA/03mddn9SJQfJSVZ3vBJmsygUma/z76ORg9JjZ uyNoAsDZ2No48azT4uK+lxmc4eaGmtGN+phzis4DG3LnXplRwzhGbZuUYgukriYo AGQtnzv0W4sgn3hjks41Iv9DR+xH+/Uq4oWiGBe8OUkRFhk/3/gTuTYP7nvqkv9R MHXC4WqHESxWBEzoyLp47PG3fLNvv17PLLxvpyEkhW1z+OcPR5Z3m1YchVeo/19d WL5C/t2xjIeNViz+kLas89LQHQZqVSmQ2Q3RpfsyA5sCCu4vuKiXRHUp16B6ReHw == X-ME-Proxy: X-ME-Sender: Received: from [192.168.1.3] (unknown [71.212.134.3]) by mail.messagingengine.com (Postfix) with ESMTPA id 09D0FE473B; Thu, 16 Aug 2018 11:13:40 -0400 (EDT) Subject: Re: Sv: Re: Sv: Re: regex match and special characters To: Andreas Joseph Krogh Cc: pgsql-general@lists.postgresql.org References: From: Adrian Klaver Message-ID: Date: Thu, 16 Aug 2018 08:13:40 -0700 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:52.0) Gecko/20100101 Thunderbird/52.9.1 MIME-Version: 1.0 In-Reply-To: Content-Type: text/plain; charset=utf-8; format=flowed Content-Language: en-US Content-Transfer-Encoding: 8bit List-Id: List-Help: List-Subscribe: List-Post: List-Owner: List-Archive: Precedence: bulk On 08/16/2018 07:47 AM, Andreas Joseph Krogh wrote: > På torsdag 16. august 2018 kl. 16:32:40, skrev Adrian Klaver > >: > > On 08/16/2018 07:04 AM, Andreas Joseph Krogh wrote: > > > char(2006) produces the wrong character as 2006 is the hex-value. You > > have to use 8198: > > andreak@[local]:543310.4 andreak=# select version(); > > > ┌────────────────────────────────────────────────────────────────────────────────────────────────┐ > > │                                            version > >                                              │ > > > ├────────────────────────────────────────────────────────────────────────────────────────────────┤ > > │ PostgreSQL 10.4 on x86_64-pc-linux-gnu, compiled by gcc (Ubuntu > > 7.3.0-16ubuntu3) 7.3.0, 64-bit │ > > > └────────────────────────────────────────────────────────────────────────────────────────────────┘ > > (1 row) > > > > andreak@[local]:543310.4 andreak=# select 'abcd'||chr(8198) ~ > 'abcd\s'; > > ┌──────────┐ > > │ ?column? │ > > ├──────────┤ > > │ t        │ > > └──────────┘ > > (1 row) > > Argh, read the wrong line. Thanks for the correction. Still: > > test=# select version(); >                                        version > > ------------------------------------------------------------------------------------ >   PostgreSQL 10.5 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux) > 4.8.5, 64-bit > (1 row) > > > test=# select 'abcd'||chr(8198) ~ E'abcd\s'; >   ?column? > ---------- >   f > (1 row) > > When using E-syntax you need to double the backslash for escaping: > andreak@[local]:543310.4 andreak=# select 'abcd'||chr(8198) ~ E'abcd\\s'; > ┌──────────┐ > │ ?column? │ > ├──────────┤ > │ t        │ > └──────────┘ > (1 row) Hmm: test=# show standard_conforming_strings; standard_conforming_strings ----------------------------- off (1 row) test=# show escape_string_warning; escape_string_warning ----------------------- on (1 row) test=# select 'abcd'||chr(8198) ~ 'abcd\s'; WARNING: nonstandard use of escape in a string literal LINE 1: select 'abcd'||chr(8198) ~ 'abcd\s'; ^ HINT: Use the escape string syntax for escapes, e.g., E'\r\n'. ?column? ---------- f (1 row) test=# select 'abcd'||chr(8198) ~ 'abcd\\s'; WARNING: nonstandard use of \\ in a string literal LINE 1: select 'abcd'||chr(8198) ~ 'abcd\\s'; ^ HINT: Use the escape string syntax for backslashes, e.g., E'\\'. ?column? ---------- t (1 row) test=# set escape_string_warning = 'off'; SET test=# show escape_string_warning; escape_string_warning ----------------------- off (1 row) test=# select 'abcd'||chr(8198) ~ 'abcd\s'; ?column? ---------- f (1 row) test=# set standard_conforming_strings = 'on'; SET test=# show standard_conforming_strings; standard_conforming_strings ----------------------------- on (1 row) test=# select 'abcd'||chr(8198) ~ 'abcd\s'; ?column? ---------- t (1 row) Wonder if the OP has standard_conforming_strings='off' and escape_string_warning='off'? > -- > *Andreas Joseph Krogh* > CTO / Partner - Visena AS > Mobile: +47 909 56 963 > andreas@visena.com > www.visena.com > -- Adrian Klaver adrian.klaver@aklaver.com