I want to convert string with all escape character.
Input
string = "Let's do this"
convert(string)
Output
Let\'s do this
Thank You!
CodePudding user response:
Your question is not clear. By escape character do you mean adding new line after certain characters or just want to add backslash do your string?
if you want to add backslash before ' character you can try below.
new_string = string.replace("'s", "\\'s")