Search code examples
sqlstringoracle-databasereplace

How can I remove backslash escaped characters from a string?


I have migrated some data from a MySQL database to an Oracle database, and in one of the migrated columns I am finding that there are backslash escaped characters like "\t" (backslash + t).

In a query for a report, i need to be able to remove the "\t" so that records can properly be aggrigated.

sample data:

table1
'\tTest Data'
'Test Data'

if I do a select distinct these two records currently show as different values, but I need them to show as the same value 'Test Data'.

I have tried:

select replace(mycol,'\\t','') from table1;

without any success.


Solution

  • Because the '\t' is in quotes you do not need to escape the backslash....

    select replace('\tTest','\t','') from dual;
    

    Returns Test as you require