Jquery String.prototype 函数扩展
来源:互联网 发布:ie淘宝首页不显示图片 编辑:程序博客网 时间:2024/04/27 18:01
- //String.prototype使用
- //批量替换,比如:str.ReplaceAll([/a/g,/b/g,/c/g],["aaa","bbb","ccc"])
- String.prototype.ReplaceAll=function (A,B) {
- var C=this;
- for(var i=0;i<A.length;i++) {
- C=C.replace(A[i],B[i]);
- };
- return C;
- };
- // 去掉字符两端的空白字符
- String.prototype.Trim=function () {
- return this.replace(/(^[/t/n/r]*)|([/t/n/r]*$)/g,'');
- };
- // 去掉字符左边的空白字符
- String.prototype.LTrim=function () {
- return this.replace(/^[/t/n/r]/g,'');
- };
- // 去掉字符右边的空白字符
- String.prototype.RTrim=function () {
- return this.replace(/[/t/n/r]*$/g,'');
- };
- // 返回字符的长度,一个中文算2个
- String.prototype.ChineseLength=function()
- {
- return this.replace(/[^/x00-/xff]/g,"**").length;
- };
- // 判断字符串是否以指定的字符串结束
- String.prototype.EndsWith=function (A,B) {
- var C=this.length;
- var D=A.length;
- if(D>C)return false;
- if(B) {
- var E=new RegExp(A+'$','i');
- return E.test(this);
- }else return (D==0||this.substr(C-D,D)==A);
- };
- // 判断字符串是否以指定的字符串开始
- String.prototype.StartsWith = function(str)
- {
- return this.substr(0, str.length) == str;
- };
- // 字符串从哪开始多长字符去掉
- String.prototype.Remove=function (A,B) {
- var s='';
- if(A>0)s=this.substring(0,A);
- if(A+B<this.length)s+=this.substring(A+B,this.length);
- return s;
- };
- // 从右边截取指定长度的子串
- String.prototype.Right=function(n){
- var str=this.slice(this.length-n);
- return str;
- }
0 0
- Jquery String.prototype 函数扩展
- java jquery扩展(prototype)
- jquery String扩展方法
- JavaScript String函数扩展
- string类扩展函数
- c++ string 扩展函数
- Kotlin 扩展函数 与 JS 的 prototype
- 扩展jQuery函数功能
- jquery扩展函数详解
- jquery框架 函数扩展
- Jquery 函数扩展
- jQuery扩展函数方法
- jQuery扩展函数
- String.prototype实现的一些javascript函数
- String.prototype实现的一些javascript函数
- 使用prototype扩展JS内部对象String的功能
- jquery 声明公用函数 prototype方法
- Lua String 的扩展函数
- 菜鸟学android——配置更改导致应用异常的处理方案
- Java异常处理机制【转载】
- 数字图像处理(笔记2)
- android反编译工具总结
- 数据存储(五)
- Jquery String.prototype 函数扩展
- Cache的组成结构
- Mobile Atlas Creator(MOBAC)编译
- cocos2d-x 通过JNI实现c/c++和Android的java层函数互调
- ZooKeeper的使用目的与场景
- javascript 转数字:javascript数字相加
- flex,spring,ibatis整合
- 玩日期
- UVA - 10003 - Cutting Sticks(动态规划)