Sv: Re: Sv: Re: regex match and special characters

From: Andreas Joseph Krogh <andreas(at)visena(dot)com>
To: Adrian Klaver <adrian(dot)klaver(at)aklaver(dot)com>
Cc: pgsql-general(at)lists(dot)postgresql(dot)org
Subject: Sv: Re: Sv: Re: regex match and special characters
Date: 2018-08-16 14:47:15
Message-ID: VisenaEmail.3c.a2f490fd2f459412.1654333b814@tc7-visena
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-general

På torsdag 16. august 2018 kl. 16:32:40, skrev Adrian Klaver <
adrian(dot)klaver(at)aklaver(dot)com <mailto:adrian(dot)klaver(at)aklaver(dot)com>>:
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(at)[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(at)[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(at)[local]:5433 10.4 andreak=# select 'abcd'||chr(8198) ~ E'abcd\\s';
┌──────────┐
│ ?column? │
├──────────┤
│ t        │
└──────────┘
(1 row)
 
 
-- Andreas Joseph Krogh
CTO / Partner - Visena AS
Mobile: +47 909 56 963
andreas(at)visena(dot)com <mailto:andreas(at)visena(dot)com>
www.visena.com <https://www.visena.com>
<https://www.visena.com>

 

In response to

Responses

Browse pgsql-general by date

  From Date Subject
Next Message Adrian Klaver 2018-08-16 15:13:40 Re: Sv: Re: Sv: Re: regex match and special characters
Previous Message Adrian Klaver 2018-08-16 14:32:40 Re: Sv: Re: regex match and special characters