I’m using Gtranslate plugin for a client website and translating some words using the apostrophe I found that the plugin add a backslash before it:
Hello I/’m going to dinner…
How can I remove the backslash before apostrophe?
There is a php fix that I can add to the plugin or should I use a javascript solution?
And can you can help me to find a good way to do it in both case?
Thanks.
A regular expression in Javascript can remove all backslashes, but there might be cases where the string really means to use a backslash. Then you would need a more specific change, from
\'to'http://jsfiddle.net/scx8t/
To specifically replace \’ write
s.replace(/\\'/g, "'")For this slash
/you would writes.replace(/\//g, ""), for both,s.replace(/[\/\\]/g, "")EDIT: For this application a PHP
preg_replaceappears more appropriate. I just don’t have a PHP running right now so I wrote Javascript 😛 Here’s what it should look like:NOTE
/\\/might need to be/\\/g. I’m not familiar with PHP.from here Example #4 Strip whitespace