[erlang-questions] String and single quote escaping

Raffaele Intorcia raffaele.intorcia@REDACTED
Wed Oct 8 15:54:06 CEST 2014


Hi all, i'm getting crazy with string and quote escaping.

I have a string like this:

 

single quote ' etc...

 

Now, i have to create a string that will be passed as query to a sqlserver
so i need to escape the single quote. To do this i'm using re:replace for
example with these syntax :

 

2> re:replace("single quote ' etc...", "'", "\'", [{return, list}]).

"single quote ' etc..."

 

2> re:replace("single quote ' etc...", "'", "\\'", [{return, list}]).

"single quote ' etc..."

 

2> re:replace("single quote ' etc...", "'", "\\\'", [{return, list}]).

"single quote ' etc..."

 

2> re:replace("single quote ' etc...", "'", "\\\'", [{return, list}]).

"single quote \\' etc..."

 

All of these results is not what i want. I'm looking for this:

 

"message with single quote \' etc..."

 

Anyone knows how i can achieve this?

 

Thank you!!

 

Bye

Raf

 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://erlang.org/pipermail/erlang-questions/attachments/20141008/2ca72961/attachment.htm>


More information about the erlang-questions mailing list