replace方法

mac2022-06-30  23

 1  function htmlEscape(text) {  2              return text.replace(/[<>"&]/g,  function (match, pos, originalText) {  3                  switch (match) {  4                      case "<":  5                          return "<";  6                      case ">":  7                          return ">";  8                      case "&":  9                          return "&"; 10                      case "\"": 11                          return """; 12                 } 13             }); 14         } 15         console.log(htmlEscape("<p class=\"greeting\">Hello world!</p>"));

转载于:https://www.cnblogs.com/qzsonline/archive/2012/03/15/2397988.html

相关资源:POS打印机通用驱动
最新回复(0)