📌  相关文章
📜  如果文本在花括号中,则替换为 div site:stackoverflow.com - Javascript 代码示例

📅  最后修改于: 2022-03-11 15:02:59.444000             🧑  作者: Mango

代码示例1
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 = "
{{foo}} and {{{bar}}} and {{{{hahahaahahahahahaha}}}}
"; document.write(getParams(string));