zoukankan      html  css  js  c++  java
  • js替换字符串的所有示例代码

    js如何替换字符串中所有。

    /** 
    
    * 替换字符串中所有 
    * @param obj 原字符串 
    * @param str1 替换规则 
    * @param str2 替换成什么 
    * @return 替换后的字符串 
    */ 
    function replaceAll(obj,str1,str2){ 
    var result = obj.replace(eval("/"+str1+"/gi"),str2); 
    return result; 
    }

    例如: 

    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> 
    <html> 
    <head> 
    <title> js替换字符串的例子-www.jbxue.com-脚本学堂 </title> 
    <meta name="Generator" content="EditPlus"> 
    <meta name="Author" content=""> 
    <meta name="Keywords" content=""> 
    <meta name="Description" content=""> 
    <script type="text/javascript"> 
    function replaceAll(obj,str1,str2){ 
    var result = obj.replace(eval("/"+str1+"/gi"),str2); 
    return result; 
    } 
    alert(replaceAll("111,222,333",",","|")); 
    </script> 
    </head> 
    <body> 
    </body> 
    </html>
  • 相关阅读:
    struts.xml
    web.xml
    jdbc.properties
    apache+tomcat的集群--Session复制配置
    mysql 定时触发器
    mysql 查看存储过程
    Quatz 定时任务
    Apache Httpd常用命令
    Mac安装nginx
    dubbo ReferenceConfig源码分析
  • 原文地址:https://www.cnblogs.com/study100/p/3209810.html
Copyright © 2011-2022 走看看