{"id":319,"date":"2010-06-05T10:10:04","date_gmt":"2010-06-05T02:10:04","guid":{"rendered":"http:\/\/elon.852128.com\/blog\/?p=319"},"modified":"2010-06-05T10:10:04","modified_gmt":"2010-06-05T02:10:04","slug":"javascript%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%bd%e6%95%b0%e5%a4%a7%e5%85%a8","status":"publish","type":"post","link":"https:\/\/elon.852128.com\/blog\/2010\/06\/05\/javascript%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%87%bd%e6%95%b0%e5%a4%a7%e5%85%a8\/","title":{"rendered":"JavaScript\u5b57\u7b26\u4e32\u51fd\u6570\u5927\u5168"},"content":{"rendered":"<p>\u81ea\u5e26\u51fd\u6570<br \/>\nconcat<br \/>\n\u5c06\u4e24\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u7684\u6587\u672c\u7ec4\u5408\u8d77\u6765\uff0c\u8fd4\u56de\u4e00\u4e2a\u65b0\u7684\u5b57\u7b26\u4e32\u3002<br \/>\nvar a = &#8220;hello&#8221;;<br \/>\nvar b = &#8220;,world&#8221;;<br \/>\nvar c = a.concat(b);<br \/>\nalert(c);<br \/>\n\/\/c = &#8220;hello,world&#8221;<br \/>\nindexOf<br \/>\n\u8fd4\u56de\u5b57\u7b26\u4e32\u4e2d\u4e00\u4e2a\u5b50\u4e32\u7b2c\u4e00\u5904\u51fa\u73b0\u7684\u7d22\u5f15\uff08\u4ece\u5de6\u5230\u53f3\u641c\u7d22\uff09\u3002\u5982\u679c\u6ca1\u6709\u5339\u914d\u9879\uff0c\u8fd4\u56de -1 \u3002<br \/>\nvar index1 = a.indexOf(&#8220;l&#8221;);<br \/>\n\/\/index1 = 2<br \/>\nvar index2 = a.indexOf(&#8220;l&#8221;,3);<br \/>\n\/\/index2 = 3<br \/>\ncharAt<br \/>\n\u8fd4\u56de\u6307\u5b9a\u4f4d\u7f6e\u7684\u5b57\u7b26\u3002<br \/>\nvar get_char = a.charAt(0);<br \/>\n\/\/get_char = &#8220;h&#8221;<br \/>\nlastIndexOf<br \/>\n\u8fd4\u56de\u5b57\u7b26\u4e32\u4e2d\u4e00\u4e2a\u5b50\u4e32\u6700\u540e\u4e00\u5904\u51fa\u73b0\u7684\u7d22\u5f15\uff08\u4ece\u53f3\u5230\u5de6\u641c\u7d22\uff09\uff0c\u5982\u679c\u6ca1\u6709\u5339\u914d\u9879\uff0c\u8fd4\u56de -1 \u3002<br \/>\nvar index1 = lastIndexOf(&#8216;l&#8217;);<br \/>\n\/\/index1 = 3<br \/>\nvar index2 = lastIndexOf(&#8216;l&#8217;,2)<br \/>\n\/\/index2 = 2<br \/>\nmatch<br \/>\n\u68c0\u67e5\u4e00\u4e2a\u5b57\u7b26\u4e32\u5339\u914d\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u5185\u5bb9\uff0c\u5982\u679c\u4e48\u6709\u5339\u914d\u8fd4\u56de null\u3002<br \/>\nvar re = new RegExp(\/^\\w+$\/);<br \/>\nvar is_alpha1 = a.match(re);<br \/>\n\/\/is_alpha1 = &#8220;hello&#8221;<br \/>\nvar is_alpha2 = b.match(re);<br \/>\n\/\/is_alpha2 = null<br \/>\nsubstring<br \/>\n\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u4e00\u4e2a\u5b50\u4e32\uff0c\u4f20\u5165\u53c2\u6570\u662f\u8d77\u59cb\u4f4d\u7f6e\u548c\u7ed3\u675f\u4f4d\u7f6e\u3002<br \/>\nvar sub_string1 = a.substring(1);<br \/>\n\/\/sub_string1 = &#8220;ello&#8221;<br \/>\nvar sub_string2 = a.substring(1,4);<br \/>\n\/\/sub_string2 = &#8220;ell&#8221;<br \/>\nsubstr<br \/>\n\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u4e00\u4e2a\u5b50\u4e32\uff0c\u4f20\u5165\u53c2\u6570\u662f\u8d77\u59cb\u4f4d\u7f6e\u548c\u957f\u5ea6<br \/>\nvar sub_string1 = a.substr(1);<br \/>\n\/\/sub_string1 = &#8220;ello&#8221;<br \/>\nvar sub_string2 = a.substr(1,4);<br \/>\n\/\/sub_string2 = &#8220;ello&#8221;<br \/>\nreplace<br \/>\n\u7528\u6765\u67e5\u627e\u5339\u914d\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u7684\u5b57\u7b26\u4e32\uff0c\u7136\u540e\u4f7f\u7528\u65b0\u5b57\u7b26\u4e32\u4ee3\u66ff\u5339\u914d\u7684\u5b57\u7b26\u4e32\u3002<br \/>\nvar result1 = a.replace(re,&#8221;Hello&#8221;);<br \/>\n\/\/result1 = &#8220;Hello&#8221;<br \/>\nvar result2 = b.replace(re,&#8221;Hello&#8221;);<br \/>\n\/\/result2 = &#8220;,world&#8221;<br \/>\nsearch<br \/>\n\u6267\u884c\u4e00\u4e2a\u6b63\u5219\u8868\u8fbe\u5f0f\u5339\u914d\u67e5\u627e\u3002\u5982\u679c\u67e5\u627e\u6210\u529f\uff0c\u8fd4\u56de\u5b57\u7b26\u4e32\u4e2d\u5339\u914d\u7684\u7d22\u5f15\u503c\u3002\u5426\u5219\u8fd4\u56de -1 \u3002<br \/>\nvar index1 = a.search(re);<br \/>\n\/\/index1 = 0<br \/>\nvar index2 = b.search(re);<br \/>\n\/\/index2 = -1<br \/>\nslice<br \/>\n\u63d0\u53d6\u5b57\u7b26\u4e32\u7684\u4e00\u90e8\u5206\uff0c\u5e76\u8fd4\u56de\u4e00\u4e2a\u65b0\u5b57\u7b26\u4e32\uff08\u4e0e substring \u76f8\u540c\uff09\u3002<br \/>\nvar sub_string1 = a.slice(1);<br \/>\n\/\/sub_string1 = &#8220;ello&#8221;<br \/>\nvar sub_string2 = a.slice(1,4);<br \/>\n\/\/sub_string2 = &#8220;ell&#8221;<br \/>\nsplit<br \/>\n\u901a\u8fc7\u5c06\u5b57\u7b26\u4e32\u5212\u5206\u6210\u5b50\u4e32\uff0c\u5c06\u4e00\u4e2a\u5b57\u7b26\u4e32\u505a\u6210\u4e00\u4e2a\u5b57\u7b26\u4e32\u6570\u7ec4\u3002<br \/>\nvar arr1 = a.split(&#8220;&#8221;);<br \/>\n\/\/arr1 = [h,e,l,l,o]<br \/>\nlength<br \/>\n\u8fd4\u56de\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\uff0c\u6240\u8c13\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u662f\u6307\u5176\u5305\u542b\u7684\u5b57\u7b26\u7684\u4e2a\u6570\u3002<br \/>\nvar len = a.length();<br \/>\n\/\/len = 5<br \/>\ntoLowerCase<br \/>\n\u5c06\u6574\u4e2a\u5b57\u7b26\u4e32\u8f6c\u6210\u5c0f\u5199\u5b57\u6bcd\u3002<br \/>\nvar lower_string = a.toLowerCase();<br \/>\n\/\/lower_string = &#8220;hello&#8221;<br \/>\ntoUpperCase<br \/>\n\u5c06\u6574\u4e2a\u5b57\u7b26\u4e32\u8f6c\u6210\u5927\u5199\u5b57\u6bcd\u3002<br \/>\nvar upper_string = a.toUpperCase();<br \/>\n\/\/upper_string = &#8220;HELLO&#8221;<\/p>\n<p>\/*<br \/>\n******************************************<br \/>\n                        \u5b57\u7b26\u4e32\u51fd\u6570\u6269\u5145<br \/>\n******************************************<br \/>\n*\/<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u53bb\u9664\u5de6\u8fb9\u7684\u7a7a\u683c<br \/>\n===========================================<\/p>\n<p>*\/<br \/>\nString.prototype.LTrim = function()<br \/>\n{<br \/>\n        return this.replace(\/(^\\s*)\/g, &#8220;&#8221;);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u53bb\u9664\u53f3\u8fb9\u7684\u7a7a\u683c<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.Rtrim = function()<br \/>\n{<br \/>\n        return this.replace(\/(\\s*$)\/g, &#8220;&#8221;);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u53bb\u9664\u524d\u540e\u7a7a\u683c<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.Trim = function()<br \/>\n{<br \/>\n        return this.replace(\/(^\\s*)|(\\s*$)\/g, &#8220;&#8221;);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u5f97\u5230\u5de6\u8fb9\u7684\u5b57\u7b26\u4e32<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.Left = function(len)<br \/>\n{<\/p>\n<p>        if(isNaN(len)||len==null)<br \/>\n        {<br \/>\n                len = this.length;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n                if(parseInt(len)<0||parseInt(len)>this.length)<br \/>\n                {<br \/>\n                        len = this.length;<br \/>\n                }<br \/>\n        }<\/p>\n<p>        return this.substr(0,len);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u5f97\u5230\u53f3\u8fb9\u7684\u5b57\u7b26\u4e32<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.Right = function(len)<br \/>\n{<\/p>\n<p>        if(isNaN(len)||len==null)<br \/>\n        {<br \/>\n                len = this.length;<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n                if(parseInt(len)<0||parseInt(len)>this.length)<br \/>\n                {<br \/>\n                        len = this.length;<br \/>\n                }<br \/>\n        }<\/p>\n<p>        return this.substring(this.length-len,this.length);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u5f97\u5230\u4e2d\u95f4\u7684\u5b57\u7b26\u4e32,\u6ce8\u610f\u4ece0\u5f00\u59cb<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.Mid = function(start,len)<br \/>\n{<br \/>\n        return this.substr(start,len);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u5728\u5b57\u7b26\u4e32\u91cc\u67e5\u627e\u53e6\u4e00\u5b57\u7b26\u4e32:\u4f4d\u7f6e\u4ece0\u5f00\u59cb<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.InStr = function(str)<br \/>\n{<\/p>\n<p>        if(str==null)<br \/>\n        {<br \/>\n                str = &#8220;&#8221;;<br \/>\n        }<\/p>\n<p>        return this.indexOf(str);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u5728\u5b57\u7b26\u4e32\u91cc\u53cd\u5411\u67e5\u627e\u53e6\u4e00\u5b57\u7b26\u4e32:\u4f4d\u7f6e0\u5f00\u59cb<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.InStrRev = function(str)<br \/>\n{<\/p>\n<p>        if(str==null)<br \/>\n        {<br \/>\n                str = &#8220;&#8221;;<br \/>\n        }<\/p>\n<p>        return this.lastIndexOf(str);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u8ba1\u7b97\u5b57\u7b26\u4e32\u6253\u5370\u957f\u5ea6<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.LengthW = function()<br \/>\n{<br \/>\n        return this.replace(\/[^\\x00-\\xff]\/g,&#8221;**&#8221;).length;<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6b63\u786e\u7684IP\u5730\u5740<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isIP = function()<br \/>\n{<\/p>\n<p>        var reSpaceCheck = \/^(\\d+)\\.(\\d+)\\.(\\d+)\\.(\\d+)$\/;<\/p>\n<p>        if (reSpaceCheck.test(this))<br \/>\n        {<br \/>\n                this.match(reSpaceCheck);<br \/>\n                if (RegExp.$1 <= 255 &#038;&#038; RegExp.$1 >= 0<br \/>\n                 &#038;&#038; RegExp.$2 <= 255 &#038;&#038; RegExp.$2 >= 0<br \/>\n                 &#038;&#038; RegExp.$3 <= 255 &#038;&#038; RegExp.$3 >= 0<br \/>\n                 &#038;&#038; RegExp.$4 <= 255 &#038;&#038; RegExp.$4 >= 0)<br \/>\n                {<br \/>\n                        return true;<br \/>\n                }<br \/>\n                else<br \/>\n                {<br \/>\n                        return false;<br \/>\n                }<br \/>\n        }<br \/>\n        else<br \/>\n        {<br \/>\n                return false;<br \/>\n        }<\/p>\n<p>}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6b63\u786e\u7684\u957f\u65e5\u671f<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isLongDate = function()<br \/>\n{<br \/>\n        var r = this.replace(\/(^\\s*)|(\\s*$)\/g, &#8220;&#8221;).match(\/^(\\d{1,4})(-|\\\/)(\\d{1,2})\\2(\\d{1,2}) (\\d{1,2}):(\\d{1,2}):(\\d{1,2})$\/);<br \/>\n        if(r==null)<br \/>\n        {<br \/>\n                return false;<br \/>\n        }<br \/>\n        var d = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]);<br \/>\n        return (d.getFullYear()==r[1]&#038;&#038;(d.getMonth()+1)==r[3]&#038;&#038;d.getDate()==r[4]&#038;&#038;d.getHours()==r[5]&#038;&#038;d.getMinutes()==r[6]&#038;&#038;d.getSeconds()==r[7]);<\/p>\n<p>}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6b63\u786e\u7684\u77ed\u65e5\u671f<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isShortDate = function()<br \/>\n{<br \/>\n        var r = this.replace(\/(^\\s*)|(\\s*$)\/g, &#8220;&#8221;).match(\/^(\\d{1,4})(-|\\\/)(\\d{1,2})\\2(\\d{1,2})$\/);<br \/>\n        if(r==null)<br \/>\n        {<br \/>\n                return false;<br \/>\n        }<br \/>\n        var d = new Date(r[1], r[3]-1, r[4]);<br \/>\n        return (d.getFullYear()==r[1]&#038;&#038;(d.getMonth()+1)==r[3]&#038;&#038;d.getDate()==r[4]);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6b63\u786e\u7684\u65e5\u671f<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isDate = function()<br \/>\n{<br \/>\n        return this.isLongDate()||this.isShortDate();<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u624b\u673a<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isMobile = function()<br \/>\n{<br \/>\n        return \/^0{0,1}13[0-9]{9}$\/.test(this);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u90ae\u4ef6<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isEmail = function()<br \/>\n{<br \/>\n        return \/^\\w+((-\\w+)|(\\.\\w+))*\\@[A-Za-z0-9]+((\\.|-)[A-Za-z0-9]+)*\\.[A-Za-z0-9]+$\/.test(this);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u90ae\u7f16(\u4e2d\u56fd)<br \/>\n===========================================<br \/>\n*\/<\/p>\n<p>String.prototype.isZipCode = function()<br \/>\n{<br \/>\n        return \/^[\\\\d]{6}$\/.test(this);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6709\u6c49\u5b57<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.existChinese = function()<br \/>\n{<br \/>\n        \/\/[\\u4E00-\\u9FA5]\u70ba\u6f22\u5b57\ufe50[\\uFE30-\\uFFA0]\u70ba\u5168\u89d2\u7b26\u865f<br \/>\n        return \/^[\\x00-\\xff]*$\/.test(this);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u5408\u6cd5\u7684\u6587\u4ef6\u540d\/\u76ee\u5f55\u540d<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isFileName = function()<br \/>\n{<br \/>\n        return !\/[\\\\\\\/\\*\\?\\|:&#8221;<>]\/g.test(this);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6709\u6548\u94fe\u63a5<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isUrl = function()<br \/>\n{<br \/>\n        return \/^http[s]?:\\\/\\\/([\\w-]+\\.)+[\\w-]+([\\w-.\/?%&#038;=]*)?$\/i.test(this);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6709\u6548\u7684\u8eab\u4efd\u8bc1(\u4e2d\u56fd)<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isIDCard = function()<br \/>\n{<br \/>\n        var iSum=0;<br \/>\n        var info=&#8221;&#8221;;<br \/>\n        var sId = this;<\/p>\n<p>        var aCity={11:&#8221;\u5317\u4eac&#8221;,12:&#8221;\u5929\u6d25&#8221;,13:&#8221;\u6cb3\u5317&#8221;,14:&#8221;\u5c71\u897f&#8221;,15:&#8221;\u5185\u8499\u53e4&#8221;,21:&#8221;\u8fbd\u5b81&#8221;,22:&#8221;\u5409\u6797&#8221;,23:&#8221;\u9ed1\u9f99\u6c5f&#8221;,31:&#8221;\u4e0a\u6d77&#8221;,32:&#8221;\u6c5f\u82cf&#8221;,33:&#8221;\u6d59\u6c5f&#8221;,34:&#8221;\u5b89\u5fbd&#8221;,35:&#8221;\u798f\u5efa&#8221;,36:&#8221;\u6c5f\u897f&#8221;,37:&#8221;\u5c71\u4e1c&#8221;,41:&#8221;\u6cb3\u5357&#8221;,42:&#8221;\u6e56\u5317&#8221;,43:&#8221;\u6e56\u5357&#8221;,44:&#8221;\u5e7f\u4e1c&#8221;,45:&#8221;\u5e7f\u897f&#8221;,46:&#8221;\u6d77\u5357&#8221;,50:&#8221;\u91cd\u5e86&#8221;,51:&#8221;\u56db\u5ddd&#8221;,52:&#8221;\u8d35\u5dde&#8221;,53:&#8221;\u4e91\u5357&#8221;,54:&#8221;\u897f\u85cf&#8221;,61:&#8221;\u9655\u897f&#8221;,62:&#8221;\u7518\u8083&#8221;,63:&#8221;\u9752\u6d77&#8221;,64:&#8221;\u5b81\u590f&#8221;,65:&#8221;\u65b0\u7586&#8221;,71:&#8221;\u53f0\u6e7e&#8221;,81:&#8221;\u9999\u6e2f&#8221;,82:&#8221;\u6fb3\u95e8&#8221;,91:&#8221;\u56fd\u5916&#8221;};<\/p>\n<p>        if(!\/^\\d{17}(\\d|x)$\/i.test(sId))<br \/>\n        {<br \/>\n                return false;<br \/>\n        }<br \/>\n        sId=sId.replace(\/x$\/i,&#8221;a&#8221;);<br \/>\n        \/\/\u975e\u6cd5\u5730\u533a<br \/>\n        if(aCity[parseInt(sId.substr(0,2))]==null)<br \/>\n        {<br \/>\n                return false;<br \/>\n        }<\/p>\n<p>        var sBirthday=sId.substr(6,4)+&#8221;-&#8220;+Number(sId.substr(10,2))+&#8221;-&#8220;+Number(sId.substr(12,2));<\/p>\n<p>        var d=new Date(sBirthday.replace(\/-\/g,&#8221;\/&#8221;))<\/p>\n<p>        \/\/\u975e\u6cd5\u751f\u65e5<br \/>\n        if(sBirthday!=(d.getFullYear()+&#8221;-&#8220;+ (d.getMonth()+1) + &#8220;-&#8221; + d.getDate()))<br \/>\n        {<br \/>\n                return false;<br \/>\n        }<br \/>\n        for(var i = 17;i>=0;i&#8211;)<br \/>\n        {<br \/>\n                iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 &#8211; i),11);<br \/>\n        }<\/p>\n<p>        if(iSum%11!=1)<br \/>\n        {<br \/>\n                return false;<br \/>\n        }<br \/>\n        return true;<\/p>\n<p>}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6709\u6548\u7684\u7535\u8bdd\u53f7\u7801(\u4e2d\u56fd)<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isPhoneCall = function()<br \/>\n{<br \/>\n        return \/(^[0-9]{3,4}\\-[0-9]{3,8}$)|(^[0-9]{3,8}$)|(^\\([0-9]{3,4}\\)[0-9]{3,8}$)|(^0{0,1}13[0-9]{9}$)\/.test(this);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u6570\u5b57<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.isNumeric = function(flag)<br \/>\n{<br \/>\n        \/\/\u9a8c\u8bc1\u662f\u5426\u662f\u6570\u5b57<br \/>\n        if(isNaN(this))<br \/>\n        {<\/p>\n<p>                return false;<br \/>\n        }<\/p>\n<p>        switch(flag)<br \/>\n        {<\/p>\n<p>                case null:        \/\/\u6570\u5b57<br \/>\n                case &#8220;&#8221;:<br \/>\n                        return true;<br \/>\n                case &#8220;+&#8221;:        \/\/\u6b63\u6570<br \/>\n                        return                \/(^\\+?|^\\d?)\\d*\\.?\\d+$\/.test(this);<br \/>\n                case &#8220;-&#8220;:        \/\/\u8d1f\u6570<br \/>\n                        return                \/^-\\d*\\.?\\d+$\/.test(this);<br \/>\n                case &#8220;i&#8221;:        \/\/\u6574\u6570<br \/>\n                        return                \/(^-?|^\\+?|\\d)\\d+$\/.test(this);<br \/>\n                case &#8220;+i&#8221;:        \/\/\u6b63\u6574\u6570<br \/>\n                        return                \/(^\\d+$)|(^\\+?\\d+$)\/.test(this);<br \/>\n                case &#8220;-i&#8221;:        \/\/\u8d1f\u6574\u6570<br \/>\n                        return                \/^[-]\\d+$\/.test(this);<br \/>\n                case &#8220;f&#8221;:        \/\/\u6d6e\u70b9\u6570<br \/>\n                        return                \/(^-?|^\\+?|^\\d?)\\d*\\.\\d+$\/.test(this);<br \/>\n                case &#8220;+f&#8221;:        \/\/\u6b63\u6d6e\u70b9\u6570<br \/>\n                        return                \/(^\\+?|^\\d?)\\d*\\.\\d+$\/.test(this);<br \/>\n                case &#8220;-f&#8221;:        \/\/\u8d1f\u6d6e\u70b9\u6570<br \/>\n                        return                \/^[-]\\d*\\.\\d$\/.test(this);<br \/>\n                default:        \/\/\u7f3a\u7701<br \/>\n                        return true;<br \/>\n        }<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u662f\u5426\u662f\u989c\u8272(#FFFFFF\u5f62\u5f0f)<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.IsColor = function()<br \/>\n{<br \/>\n        var temp        = this;<br \/>\n        if (temp==&#8221;&#8221;) return true;<br \/>\n        if (temp.length!=7) return false;<br \/>\n        return (temp.search(\/\\#[a-fA-F0-9]{6}\/) != -1);<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u8f6c\u6362\u6210\u5168\u89d2<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.toCase = function()<br \/>\n{<br \/>\n        var tmp = &#8220;&#8221;;<br \/>\n        for(var i=0;i<this.length;i++)\n        {\n                if(this.charCodeAt(i)>0&#038;&#038;this.charCodeAt(i)<255)\n                {\n                        tmp += String.fromCharCode(this.charCodeAt(i)+65248);\n                }\n                else\n                {\n                        tmp += String.fromCharCode(this.charCodeAt(i));\n                }\n        }\n        return tmp\n}\n\n\/*\n===========================================\n\/\/\u5bf9\u5b57\u7b26\u4e32\u8fdb\u884cHtml\u7f16\u7801\n===========================================\n*\/\nString.prototype.toHtmlEncode = function()\n{\n        var str = this;\n\n        str=str.replace(\/&#038;\/g,\"&amp;\");\n        str=str.replace(\/<\/g,\"&lt;\");\n        str=str.replace(\/>\/g,&#8221;&gt;&#8221;);<br \/>\n        str=str.replace(\/\\&#8217;\/g,&#8221;&apos;&#8221;);<br \/>\n        str=str.replace(\/\\&#8221;\/g,&#8221;&quot;&#8221;);<br \/>\n        str=str.replace(\/\\n\/g,&#8221;<br \/>&#8220;);<br \/>\n        str=str.replace(\/\\ \/g,&#8221;&nbsp;&#8220;);<br \/>\n        str=str.replace(\/\\t\/g,&#8221;&nbsp;&nbsp;&nbsp;&nbsp;&#8220;);<\/p>\n<p>        return str;<br \/>\n}<\/p>\n<p>\/*<br \/>\n===========================================<br \/>\n\/\/\u8f6c\u6362\u6210\u65e5\u671f<br \/>\n===========================================<br \/>\n*\/<br \/>\nString.prototype.toDate = function()<br \/>\n{<br \/>\n        try<br \/>\n        {<br \/>\n                return new Date(this.replace(\/-\/g, &#8220;\\\/&#8221;));<br \/>\n        }<br \/>\n        catch(e)<br \/>\n        {<br \/>\n                return null;<br \/>\n        }<br \/>\n} <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u81ea\u5e26\u51fd\u6570 concat \u5c06\u4e24\u4e2a\u6216\u591a\u4e2a\u5b57\u7b26\u7684\u6587\u672c\u7ec4\u5408\u8d77\u6765\uff0c\u8fd4\u56de\u4e00\u4e2a\u65b0&#8230;<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-319","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/posts\/319","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/comments?post=319"}],"version-history":[{"count":1,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions"}],"predecessor-version":[{"id":320,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/posts\/319\/revisions\/320"}],"wp:attachment":[{"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/media?parent=319"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/categories?post=319"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/elon.852128.com\/blog\/wp-json\/wp\/v2\/tags?post=319"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}