I try to extract the non-white space character from a string using REGEXP_SUBSTR.
I use this regex \s*([^\s]*)\s*
and extract the first group
Using \s
to denote white spaces as documented
here removes the leading spaces, but preserves the training once.
select '"'||REGEXP_SUBSTR( ' xxx ', '\s*([^\s]*)\s*', 1, 1, NULL, 1 )||'"' AS text
from dual;
"xxx "
Only if I switch to the POSIX syntax as documented for 10g I get the expected result.
select '"'||REGEXP_SUBSTR( ' xxx ', '\s*([^[:space:]]*)[:space:]*', 1, 1, NULL, 1 )||'"' AS text
from dual;
"xxx"
What's (I'm doing) wrong?
I'm on 12.1.0.2.0
NLS_CHARACTERSET WE8MSWIN1252