How to replace an escape character with a string

I am trying to replace an escape character with a string, but the query gives me an irrelevant result

eg- char - '\' replace with "adfc" below request

SELECT REPLACE("abcdefgh\i","\\", "adfc" ); 

output - abcdefghi

Desired conclusion - abcdefghadfci

How can I achieve this in mysql?

+5
source share
2 answers

in my.ini add this line:

 sql-mode="NO_BACKSLASH_ESCAPES" 

then restart the mysql server and replace the query with the following:

 SELECT REPLACE("abcdefgh\i","\", "adfc" ); 

link here

+2
source

use this:

 SELECT REPLACE("abcdefgh\\i","\\", "adfc" ); 

a single escape character will automatically exit the character, so you need to put a double escape character to remove the escape character.

0
source

Source: https://habr.com/ru/post/1243135/


All Articles