When using the expression '(\S.*\S)' to remove surrounding whitespace (including \t and \n) it returns NULL on single character surrounded by whitespace.
The following shows the unexpected result:
SELECT x, '|'||substring(x, '(\S.*\S)')||'|'
FROM (VALUES (' a'), (' ab'), (' a b c '), (E' c\n'), (E' ab\n')) AS z (x);
x │ ?column?
──────────┼──────────
a │ <=== ERROR
ab │ |ab|
a b c │ |a b c|
c ↵│ <=== ERROR
│
ab ↵│ |ab|
Regards,
Per-Åke Ling