in reply to How to escape single quote(s) without the use of quotemeta
In my experience, with this kind of question, it helps to know exactly what format is expected. First, you said "I only need to escape the specific character '", which is easily solved by hippo's suggestion of s/'/\\'/g, but later on you said "I thought also about escaping the back slash character" - so do you want to escape both backslashes and single quotes? Are there maybe any more characters? In other words, what will you be using these strings for, what API are you passing them to? That would be a good reference for the expected format.
|
---|
Replies are listed 'Best First'. | |
---|---|
Re^2: How to escape single quote(s) without the use of quotemeta
by LanX (Saint) on Apr 05, 2019 at 18:58 UTC |