I've got query
select(REGEXP_MATCHES('isu_lib.directions_directions_isumapping direction_id bigint null 0', '([^\s] )'))
it shows only first word - isu_lib.directions_directions_isumapping,
but I need 'isu_lib.directions_directions_isumapping direction_id'
Another words - everything before second space.
How to change query? Postgres 11 version
CodePudding user response:
How about just using SUBSTRING()
:
SELECT SUBSTRING(col FROM '^[^ ] [^ ]*')
FROM yourTable;
Demo
The regex pattern used here says to match:
^
from the start of the string[^ ]
a non space term[^ ]*
another non space term, if it is available