Re: Substring expression fails on single character input

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Per-Åke Ling <perake(dot)ling(at)gmail(dot)com>
Cc: pgsql-bugs(at)lists(dot)postgresql(dot)org
Subject: Re: Substring expression fails on single character input
Date: 2020-05-12 14:10:28
Message-ID: 18207.1589292628@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

=?UTF-8?Q?Per=2D=C3=85ke_Ling?= <perake(dot)ling(at)gmail(dot)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

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message PG Bug reporting form 2020-05-12 14:47:04 BUG #16430: Sequence with cache > 1 makes it increment by number specified as cache
Previous Message Per-Åke Ling 2020-05-12 12:28:43 Substring expression fails on single character input