pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Per-Åke Ling <perake.ling@gmail.com>
Cc: pgsql-bugs@lists.postgresql.org
Subject: Re: Substring expression fails on single character input
Date: Tue, 12 May 2020 10:10:28 -0400
Message-ID: <18207.1589292628@sss.pgh.pa.us> (raw)
In-Reply-To: <CACCP6e-Zt8gSoH=PMCLHvGgi-CYYAAi9TE3FrfYcMUjO5BXG9Q@mail.gmail.com>
References: <CACCP6e-Zt8gSoH=PMCLHvGgi-CYYAAi9TE3FrfYcMUjO5BXG9Q@mail.gmail.com>

=?UTF-8?Q?Per=2D=C3=85ke_Ling?= <perake.ling@gmail.com> writes:
> When using the expression *'(\S.*\S)' *to remove surrounding whitespace
> (including \t and \n) it returns NULL on single character surrounded by
> whitespace.

I see no bug there.  The pattern requires two non-white-space characters
surrounding some arbitrary text, and your examples don't have that.

If your goal is to trim leading/trailing whitespace I'd suggest that btrim
is a lot easier route to the goal than coming up with a correct regex.

			regards, tom lane





view thread (2+ messages)

Message-ID: <18207.1589292628@sss.pgh.pa.us>
Permalink:  ../18207.1589292628@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/18207.1589292628@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients using the --to and --cc options:
  reply via email

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, perake.ling@gmail.com, pgsql-bugs@lists.postgresql.org
  Subject: Re: Substring expression fails on single character input
  In-Reply-To: <18207.1589292628@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

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