Answers for "if text is in curly braces replace to div site:stackoverflow.com"

0

if text is in curly braces replace to div site:stackoverflow.com

function getParams(input){
  var matches = [];
  input.replace(/(\{+)([^}]+)(}+)/g,function(orig,lb,txt,rb){
      if (lb.length === rb.length)
        matches.push(txt);
  });
  return matches;
}
var string = "<div>{{foo}} and {{{bar}}} and {{{{hahahaahahahahahaha}}}}</div>";
document.write(getParams(string));
Posted by: Guest on August-10-2021

Code answers related to "if text is in curly braces replace to div site:stackoverflow.com"

Code answers related to "Javascript"

Browse Popular Code Answers by Language