Home > DeveloperSection > Forums > Using %string% instead of {{string}} in a RegEx
john rob

Total Post:108

Posted on    September-28-2013 4:19 AM


 1 Reply(s)
 1007  View(s)
Rate this:
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}}?

Ankita Pandey
Ankita Pandey

Total Post:183

Posted on    September-28-2013 6:54 AM

Hi John!

Your current pattern actually doesn't match double curly braces, it matches only single curly braces, but anyway if you want to match %string% then you can use:


Don't want to miss updates? Please click the below button!

Follow MindStick