I am working with PostgreSQL and I can not perform a replacement query with REGEXP_REPLACE . What I need is for the column to go from what it looks like on the left side to what it appears on the right side:
------------- -------------
-- original -- modificado
------------- -------------
142/16 142
145/16 145
146/16 146
147/16 147
16/F/2016 16
213/G/2016 213
233-M-2015 233
24/G/2016 24
24/S/2016 24
25/L/2016 25
269/S/2016 269
28/S/2016 28
I need to only keep the value before '/' or '-'.
I've tried things like:
SELECT
columna AS original,
REGEXP_REPLACE(columna, '/(\w)*(\d)*', '') AS modificado
FROM tabla;
SELECT
columna AS original,
REGEXP_REPLACE(columna, '^/[a-zA-Y0-9 ]', '', 'gi') AS modificado
FROM tabla;
SELECT
columna AS original,
REGEXP_REPLACE(columna, '(/[\d*+])(\w)', '', 'gi') AS modificado
FROM tabla;
... but none throws me what I need.
Someone who can guide me or give me a hand. Thanks from now.