zoukankan      html  css  js  c++  java
  • 模仿C#中的String.Format功能

    <script type="text/javascript">
                
    var str ;
                String.prototype.template 
    = function()
                {
                    
    var args = arguments;                
                    
    return this.replace(/\{(\d+)\}/g,function(m,i)
                                                        {
                                                            
    return args[i];
                                                        }
                                         );
                };
                
                
    var a = "I Love {0}, and You Love {1},Where are {0}!";
                alert(a.template(
    "You","Me"));
                
            
    </script>
    以上代码参考网络资源,只供学习
    转载请注明出处[http://samlin.cnblogs.com/

    欢迎关注本人公众号:

    作者赞赏
  • 相关阅读:
    递归(四):组合
    递归(三):排列
    递归(二):正整数的拆分
    Python sum() 函数
    Python pow() 函数
    Python isinstance() 函数
    Python eval() 函数
    Python any() 函数
    阅读笔记1(面试题功能测试-自动化提升效率)
    sql查询(转)
  • 原文地址:https://www.cnblogs.com/samlin/p/1053610.html
Copyright © 2011-2022 走看看