You have still been provided the solution to your problem, all the code fragments posted above will replace commas in a string with the back-slash character.

Please explain in detail why this does not solve your originally posted problem
How can I replace these commas with a "\"?
There are two types of vessels, submarines and targets.