I want to replace one or more question marks with a replacement (template language), like that:
var translation = "this is a ???";
console.log(translation.replace(/(\?+)/g, "replacement")); //this is a replacement
But now, I recently ran into an issue where the question mark was actually intended as a question and should not be escaped. I decided to go for the ~
as escaping character, so this should not be escaped:
var translation = "this should not be escaped, cause it's a question, is it~?";
console.log(translation.replace(/[^~](\?+)/g, "replacement"));
Works so far. However, if I go with multiple question marks (requirement for the template syntax), I end up with crap:
var translation = "this should not be escaped, cause it's a question, is it~???";
console.log(translation.replace(/[^~](\?+)/g, "replacement"));
//this should not be escaped, cause it's a question, is it~replacement <-- ???
Any suggestion on how to do that? A classical \
as escaping character would make me happier than the ~
but I ran into issues with that as well.