Saturday, 28 September 2013

Using %string% instead of {{string}} in a RegEx

Using %string% instead of {{string}} in a RegEx

To translate some strings in my HTML, I'm using the following function
which is working totally fine to replace every string coming in double
curly braces:
var translation = html.replace(/\{[^\}]*\}/g, function(match){
// where the magic happens
});
How can I change the RegEx to match the pattern %string% instead of
{{string}}?

No comments:

Post a Comment