pg.ddx.io pgsql-general@postgresql.org mailing list archive
help / color / mirror / Atom feedSv: Re: Sv: Re: regex match and special characters
5+ messages / 3 participants
[nested] [flat]
* Sv: Re: Sv: Re: regex match and special characters
@ 2018-08-16 14:47 Andreas Joseph Krogh <andreas@visena.com>
2018-08-16 15:13 ` Re: Sv: Re: Sv: Re: regex match and special characters Adrian Klaver <adrian.klaver@aklaver.com>
2018-08-16 15:18 ` Re: Sv: Re: Sv: Re: regex match and special characters Tom Lane <tgl@sss.pgh.pa.us>
0 siblings, 2 replies; 5+ messages in thread
From: Andreas Joseph Krogh @ 2018-08-16 14:47 UTC (permalink / raw)
To: Adrian Klaver <adrian.klaver@aklaver.com>; +Cc: pgsql-general@lists.postgresql.org
På torsdag 16. august 2018 kl. 16:32:40, skrev Adrian Klaver <
adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.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@[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]: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@visena.com <mailto:andreas@visena.com>
www.visena.com <https://www.visena.com;
<https://www.visena.com;
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Sv: Re: Sv: Re: regex match and special characters
2018-08-16 14:47 Sv: Re: Sv: Re: regex match and special characters Andreas Joseph Krogh <andreas@visena.com>
@ 2018-08-16 15:13 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-08-16 15:19 ` Re: Sv: Re: Sv: Re: regex match and special characters Adrian Klaver <adrian.klaver@aklaver.com>
1 sibling, 1 reply; 5+ messages in thread
From: Adrian Klaver @ 2018-08-16 15:13 UTC (permalink / raw)
To: Andreas Joseph Krogh <andreas@visena.com>; +Cc: pgsql-general@lists.postgresql.org
On 08/16/2018 07:47 AM, Andreas Joseph Krogh wrote:
> På torsdag 16. august 2018 kl. 16:32:40, skrev Adrian Klaver
> <adrian.klaver@aklaver.com <mailto:adrian.klaver@aklaver.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@[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 <mailto:andreas@visena.com>
> www.visena.com <https://www.visena.com;
> <https://www.visena.com;
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Sv: Re: Sv: Re: regex match and special characters
2018-08-16 14:47 Sv: Re: Sv: Re: regex match and special characters Andreas Joseph Krogh <andreas@visena.com>
2018-08-16 15:13 ` Re: Sv: Re: Sv: Re: regex match and special characters Adrian Klaver <adrian.klaver@aklaver.com>
@ 2018-08-16 15:19 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-08-16 15:38 ` Re: Sv: Re: Sv: Re: regex match and special characters Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 1 reply; 5+ messages in thread
From: Adrian Klaver @ 2018-08-16 15:19 UTC (permalink / raw)
To: Andreas Joseph Krogh <andreas@visena.com>; +Cc: pgsql-general@lists.postgresql.org
On 08/16/2018 08:13 AM, Adrian Klaver wrote:
>
>
> Wonder if the OP has standard_conforming_strings='off' and
> escape_string_warning='off'?
In the above referring to 9.6.9 instance.
>
>
>
>> --
>> *Andreas Joseph Krogh*
>> CTO / Partner - Visena AS
>> Mobile: +47 909 56 963
>> andreas@visena.com <mailto:andreas@visena.com>
>> www.visena.com <https://www.visena.com;
>> <https://www.visena.com;
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Sv: Re: Sv: Re: regex match and special characters
2018-08-16 14:47 Sv: Re: Sv: Re: regex match and special characters Andreas Joseph Krogh <andreas@visena.com>
2018-08-16 15:13 ` Re: Sv: Re: Sv: Re: regex match and special characters Adrian Klaver <adrian.klaver@aklaver.com>
2018-08-16 15:19 ` Re: Sv: Re: Sv: Re: regex match and special characters Adrian Klaver <adrian.klaver@aklaver.com>
@ 2018-08-16 15:38 ` Adrian Klaver <adrian.klaver@aklaver.com>
0 siblings, 0 replies; 5+ messages in thread
From: Adrian Klaver @ 2018-08-16 15:38 UTC (permalink / raw)
To: Andreas Joseph Krogh <andreas@visena.com>; +Cc: pgsql-general@lists.postgresql.org
On 08/16/2018 08:19 AM, Adrian Klaver wrote:
> On 08/16/2018 08:13 AM, Adrian Klaver wrote:
>
>>
>>
>> Wonder if the OP has standard_conforming_strings='off' and
>> escape_string_warning='off'?
>
> In the above referring to 9.6.9 instance.
Well that theory is no good:
test=# select version();
version
-------------------------------------------------------------------------------------
PostgreSQL 9.6.7 on x86_64-pc-linux-gnu, compiled by gcc (SUSE Linux)
4.8.5, 64-bit
(1 row)
test=# set standard_conforming_strings='off';
SET
test=# show standard_conforming_strings;
standard_conforming_strings
-----------------------------
off
test=# show escape_string_warning;
escape_string_warning
-----------------------
off
test=# select 'abcd'||chr(8198) ~ E'abcd\s';
?column?
----------
f
(1 row)
test=# select 'abcd'||chr(8198) ~ E'abcd\\s';
?column?
----------
f
(1 row)
test=# set escape_string_warning='on';
SET
test=# set standard_conforming_strings='on';
SET
test=# select 'abcd'||chr(8198) ~ 'abcd\s';
?column?
----------
f
(1 row)
test=# select 'abcd'||chr(8198) ~ E'abcd\\s';
?column?
----------
f
(1 row)
>>
>>
>>
>>> --
>>> *Andreas Joseph Krogh*
>>> CTO / Partner - Visena AS
>>> Mobile: +47 909 56 963
>>> andreas@visena.com <mailto:andreas@visena.com>
>>> www.visena.com <https://www.visena.com;
>>> <https://www.visena.com;
>>
>>
>
>
--
Adrian Klaver
adrian.klaver@aklaver.com
^ permalink raw reply [nested|flat] 5+ messages in thread
* Re: Sv: Re: Sv: Re: regex match and special characters
2018-08-16 14:47 Sv: Re: Sv: Re: regex match and special characters Andreas Joseph Krogh <andreas@visena.com>
@ 2018-08-16 15:18 ` Tom Lane <tgl@sss.pgh.pa.us>
1 sibling, 0 replies; 5+ messages in thread
From: Tom Lane @ 2018-08-16 15:18 UTC (permalink / raw)
To: Andreas Joseph Krogh <andreas@visena.com>; +Cc: Adrian Klaver <adrian.klaver@aklaver.com>; pgsql-general@lists.postgresql.org
Andreas Joseph Krogh <andreas@visena.com> writes:
> When using E-syntax you need to double the backslash for escaping:
> andreak@[local]:5433 10.4 andreak=# select 'abcd'||chr(8198) ~ E'abcd\\s';
Another thing to keep in mind is that this is all locale-dependent
(specifically, LC_CTYPE, I believe). In plain old C locale, nothing
beyond the standard ASCII whitespace characters will match \s. I'm not
sure how universal it is for other locales to treat characters like
U+2006 as whitespace.
regards, tom lane
^ permalink raw reply [nested|flat] 5+ messages in thread
end of thread, other threads:[~2018-08-16 15:38 UTC | newest]
Thread overview: 5+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2018-08-16 14:47 Sv: Re: Sv: Re: regex match and special characters Andreas Joseph Krogh <andreas@visena.com>
2018-08-16 15:13 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-08-16 15:19 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-08-16 15:38 ` Adrian Klaver <adrian.klaver@aklaver.com>
2018-08-16 15:18 ` Tom Lane <tgl@sss.pgh.pa.us>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox