zoukankan      html  css  js  c++  java
  • replace方法

     1 function htmlEscape(text) {
     2             return text.replace(/[<>"&]/g, function (match, pos, originalText) {
     3                 switch (match) {
     4                     case "<":
     5                         return "&lt;";
     6                     case ">":
     7                         return "&gt;";
     8                     case "&":
     9                         return "&amp;";
    10                     case "\"":
    11                         return "&quot;";
    12                 }
    13             });
    14         }
    15         console.log(htmlEscape("<p class=\"greeting\">Hello world!</p>"));
  • 相关阅读:
    Linux文件和目录管理常用重要命令
    Windows和Linux下Mysql 重置root 密码
    瀑布流vue-waterfall的高度设置
    vue-cli 引入axios及跨域使用
    Vue 脱坑记
    shell基础
    正则
    安装卸载
    压缩打包
    vim工具
  • 原文地址:https://www.cnblogs.com/qzsonline/p/2397988.html
Copyright © 2011-2022 走看看