拼接正則

code

var v='aa'
       var re =new RegExp("^\\d+" + v + "$","gim");
        re爲:    /^\d+aa$/gim



      var re =new RegExp("^\\d+" + v + "$","gim"); // re爲/^\d+bl$/gim

2

var decimalLen =1
                var re = new RegExp("^((0(\\.[0-9]{0," + decimalLen +"})?)|([1-9][0-9]*(\\.[0-9]{0,"+ decimalLen + "})?))$","g");

undefined var re2 = /^((0(.[0-9]{0,1})?)|([1-9][0-9](.[0-9]{0,1})?))$/g undefined re /^((0(.[0-9]{0,1})?)|([1-9][0-9](.[0-9]{0,1})?))$/g re2 /^((0(.[0-9]{0,1})?)|([1-9][0-9]*(.[0-9]{0,1})?))$/gci

相關文章
相關標籤/搜索