I need help with REGEXP_REPLACE on an Oracle database. I wanted to cut everything from the following string to the phrase [Teradata Database] and leave the rest, and if [Teradata Database] is not in the string then leave it unchanged.
I have tried to solve this problem in this way, but unfortunately it does not work.
select TRIM(REGEXP_REPLACE('2021.07.29 13:45:36 ERR GEOSPATIAL_LOCATOR_CBS.sql /mup/projects/IDM IDM IdmLoadDetailLayer.sql 226 3706 42000 [Teradata Database] [TeraJDBC 17.10.00.14] [Error 3706] [SQLState 42000] IDM_UPSERT_FORMER:Syntax error: expected something between '','' and '',''.', '.*(\[Teradata Database\] : .* [^.]+)')) AS ERROR_MESSAGE from dual;
Correct result:
[Teradata Database] [TeraJDBC 17.10.00.14] [Error 3706] [SQLState 42000] IDM_UPSERT_FORMER:Syntax error: expected something between ',' and ','.
Thanks in advance for your help