JS去除字符串中的空格,比如435,567,25.00得到43556725.00

温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
阅读(7159)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_',
blogTitle:'JS去除指定字符串几种方法',
blogAbstract:' 转自
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}JS去除字符串中的,比如435,567,25.00得到_百度知道温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!&&|&&
LOFTER精选
网易考拉推荐
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
/*******************************************&&&&&&&&&&&&&&&&&&&&&&& 字符串函数扩充&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& *******************************************/ /*===========================================//去除左边的空格=========================================== */String.prototype.LTrim = function(){&&&&&&& return this.replace(/(^/s*)/g, "");} /*===========================================//去除右边的空格===========================================*/String.prototype.Rtrim = function(){&&&&&&& return this.replace(/(/s*$)/g, "");} & /*===========================================//去除前后空格===========================================*/String.prototype.Trim = function(){&&&&&&& return this.replace(/(^/s*)|(/s*$)/g, "");} /*===========================================//得到左边的字符串===========================================*/String.prototype.Left = function(len){ &&&&&&& if(isNaN(len)||len==null)&&&&&&& {&&&&&&&&&&&&&&& len = this.&&&&&&& }&&&&&&& else&&&&&&& {&&&&&&&&&&&&&&& if(parseInt(len)&0||parseInt(len)&this.length)&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&& len = this.&&&&&&&&&&&&&&& }&&&&&&& }&&&&&&& &&&&&&& return this.substr(0,len);} /*===========================================//得到右边的字符串===========================================*/String.prototype.Right = function(len){ &&&&&&& if(isNaN(len)||len==null)&&&&&&& {&&&&&&&&&&&&&&& len = this.&&&&&&& }&&&&&&& else&&&&&&& {&&&&&&&&&&&&&&& if(parseInt(len)&0||parseInt(len)&this.length)&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&& len = this.&&&&&&&&&&&&&&& }&&&&&&& }&&&&&&& &&&&&&& return this.substring(this.length-len,this.length);} /*===========================================//得到中间的字符串,注意从0开始===========================================*/String.prototype.Mid = function(start,len){&&&&&&& return this.substr(start,len);} /*===========================================//在字符串里查找另一字符串:位置从0开始===========================================*/String.prototype.InStr = function(str){ &&&&&&& if(str==null)&&&&&&& {&&&&&&&&&&&&&&& str = "";&&&&&&& }&&&&&&& &&&&&&& return this.indexOf(str);} /*===========================================//在字符串里反向查找另一字符串:位置0开始===========================================*/String.prototype.InStrRev = function(str){ &&&&&&& if(str==null)&&&&&&& {&&&&&&&&&&&&&&& str = "";&&&&&&& }&&&&&&& &&&&&&& return this.lastIndexOf(str);} & /*===========================================//计算字符串打印长度===========================================*/String.prototype.LengthW = function(){&&&&&&& return this.replace(/[^/x00-/xff]/g,"**").} /*===========================================//是否是正确的IP地址===========================================*/String.prototype.isIP = function(){ &&&&&&& var reSpaceCheck = /^(/d+)/.(/d+)/.(/d+)/.(/d+)$/; &&&&&&& if (reSpaceCheck.test(this))&&&&&&& {&&&&&&&&&&&&&&& this.match(reSpaceCheck);&&&&&&&&&&&&&&& if (RegExp.$1 &= 255 && RegExp.$1 &= 0 &&&&&&&&&&&&&&&& && RegExp.$2 &= 255 && RegExp.$2 &= 0 &&&&&&&&&&&&&&&& && RegExp.$3 &= 255 && RegExp.$3 &= 0 &&&&&&&&&&&&&&&& && RegExp.$4 &= 255 && RegExp.$4 &= 0) &&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&& }&&&&&&&&&&&&&&& else&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& }&&&&&&& }&&&&&&& else&&&&&&& {&&&&&&&&&&&&&&&&&&&&&& }&& } /*===========================================//是否是正确的长日期===========================================*/String.prototype.isLongDate = function(){&&&&&&&
var r = this.replace(/(^/s*)|(/s*$)/g,
"").match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})
(/d{1,2}):(/d{1,2}):(/d{1,2})$/); &&&&&&& if(r==null)&&&&&&& {&&&&&&&&&&&&&&& &&&&&&& }&&&&&&& var d = new Date(r[1], r[3]-1,r[4],r[5],r[6],r[7]); &&&&&&&
(d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]&&d.getHours()==r[5]&&d.getMinutes()==r[6]&&d.getSeconds()==r[7]); } /*===========================================//是否是正确的短日期===========================================*/String.prototype.isShortDate = function(){&&&&&&& var r = this.replace(/(^/s*)|(/s*$)/g, "").match(/^(/d{1,4})(-|//)(/d{1,2})/2(/d{1,2})$/); &&&&&&& if(r==null)&&&&&&& {&&&&&&&&&&&&&&& &&&&&&& }&&&&&&& var d = new Date(r[1], r[3]-1, r[4]); &&&&&&& return (d.getFullYear()==r[1]&&(d.getMonth()+1)==r[3]&&d.getDate()==r[4]);} /*===========================================//是否是正确的日期===========================================*/String.prototype.isDate = function(){&&&&&&& return this.isLongDate()||this.isShortDate();} /*===========================================//是否是手机===========================================*/String.prototype.isMobile = function(){&&&&&&& return /^0{0,1}13[0-9]{9}$/.test(this);} /*===========================================//是否是邮件===========================================*/String.prototype.isEmail = function(){&&&&&&& return /^/w+((-/w+)|(/./w+))*/@[A-Za-z0-9]+((/.|-)[A-Za-z0-9]+)*/.[A-Za-z0-9]+$/.test(this);} /*===========================================//是否是邮编(中国)===========================================*/ String.prototype.isZipCode = function(){&&&&&&& return /^[//d]{6}$/.test(this);} /*===========================================//是否是有汉字===========================================*/String.prototype.existChinese = function(){&&&&&&& //[/u4E00-/u9FA5]為漢字﹐[/uFE30-/uFFA0]為全角符號&&&&&&& return /^[/x00-/xff]*$/.test(this);} /*===========================================//是否是合法的文件名/目录名===========================================*/String.prototype.isFileName = function(){&&&&&&& return !/[/////*/?/|:"&&]/g.test(this);} /*===========================================//是否是有效链接===========================================*/String.prototype.isUrl = function(){&&&&&&& return /^http[s]?:////([/w-]+/.)+[/w-]+([/w-./?%&=]*)?$/i.test(this);} /*===========================================//是否是有效的身份证(中国)===========================================*/String.prototype.isIDCard = function(){&&&&&&& var iSum=0;&&&&&&& var info="";&&&&&&& var sId = &&&&&&& var
aCity={11:"北京",12:"天津",13:"河北",14:"山西",15:"内蒙古",21:"辽宁",22:"吉林",23:"黑龙江
",31:"上海",32:"江苏",33:"浙江",34:"安徽",35:"福建",36:"江西",37:"山东",41:"河南",42:"湖北
",43:"湖南",44:"广东",45:"广西",46:"海南",50:"重庆",51:"四川",52:"贵州",53:"云南",54:"西藏
",61:"陕西",62:"甘肃",63:"青海",64:"宁夏",65:"新疆",71:"台湾",81:"香港",82:"澳门",91:"国外
"}; &&&&&&& if(!/^/d{17}(/d|x)$/i.test(sId))&&&&&&& {&&&&&&&&&&&&&&&&&&&&&& }&&&&&&& sId=sId.replace(/x$/i,"a");&&&&&&& //非法地区&&&&&&& if(aCity[parseInt(sId.substr(0,2))]==null)&&&&&&& {&&&&&&&&&&&&&&&&&&&&&& } &&&&&&& var sBirthday=sId.substr(6,4)+"-"+Number(sId.substr(10,2))+"-"+Number(sId.substr(12,2)); &&&&&&& var d=new Date(sBirthday.replace(/-/g,"/"))&&&&&&& &&&&&&& //非法生日&&&&&&& if(sBirthday!=(d.getFullYear()+"-"+ (d.getMonth()+1) + "-" + d.getDate()))&&&&&&& {&&&&&&&&&&&&&&&&&&&&&& }&&&&&&& for(var i = 17;i&=0;i--) &&&&&&& {&&&&&&&&&&&&&&& iSum += (Math.pow(2,i) % 11) * parseInt(sId.charAt(17 - i),11);&&&&&&& } &&&&&&& if(iSum%11!=1)&&&&&&& {&&&&&&&&&&&&&&&&&&&&&& }&&&&&&& } /*===========================================//是否是有效的电话号码(中国)===========================================*/String.prototype.isPhoneCall = function(){&&&&&&& 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);} /*===========================================//是否是数字===========================================*/String.prototype.isNumeric = function(flag){&&&&&&& //验证是否是数字&&&&&&& if(isNaN(this))&&&&&&& { &&&&&&&&&&&&&&&&&&&&&& } &&&&&&& switch(flag)&&&&&&& { &&&&&&&&&&&&&&& case null:&&&&&&& //数字&&&&&&&&&&&&&&& case "":&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& case "+":&&&&&&& //正数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /(^/+?|^/d?)/d*/.?/d+$/.test(this);&&&&&&&&&&&&&&& case "-":&&&&&&& //负数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /^-/d*/.?/d+$/.test(this);&&&&&&&&&&&&&&& case "i":&&&&&&& //整数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /(^-?|^/+?|/d)/d+$/.test(this);&&&&&&&&&&&&&&& case "+i":&&&&&&& //正整数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /(^/d+$)|(^/+?/d+$)/.test(this);&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&& case "-i":&&&&&&& //负整数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /^[-]/d+$/.test(this);&&&&&&&&&&&&&&& case "f":&&&&&&& //浮点数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /(^-?|^/+?|^/d?)/d*/./d+$/.test(this);&&&&&&&&&&&&&&& case "+f":&&&&&&& //正浮点数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /(^/+?|^/d?)/d*/./d+$/.test(this);&&&&&&&&&&&&&&&&&&&&&&& &&&&&&&&&&&&&&& case "-f":&&&&&&& //负浮点数&&&&&&&&&&&&&&&&&&&&&&& return&&&&&&&&&&&&&&& /^[-]/d*/./d$/.test(this);&&&&&&&&&&&&&&& &&&&&&&&&&&&&&& default:&&&&&&& //缺省&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&&& &&&&&&& }} /*===========================================//是否是颜色(#FFFFFF形式)===========================================*/String.prototype.IsColor = function(){&&&&&&& var temp&&&&&&& =&&&&&&& if (temp=="")&&&&&&& if (temp.length!=7)&&&&&&& return (temp.search(//#[a-fA-F0-9]{6}/) != -1);} /*===========================================//转换成全角===========================================*/String.prototype.toCase = function(){&&&&&&& var tmp = "";&&&&&&& for(var i=0;i&this.i++)&&&&&&& {&&&&&&&&&&&&&&& if(this.charCodeAt(i)&0&&this.charCodeAt(i)&255)&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&& tmp += String.fromCharCode(this.charCodeAt(i)+65248);&&&&&&&&&&&&&&& }&&&&&&&&&&&&&&& else&&&&&&&&&&&&&&& {&&&&&&&&&&&&&&&&&&&&&&& tmp += String.fromCharCode(this.charCodeAt(i));&&&&&&&&&&&&&&& }&&&&&&& }&&&&&&& return tmp} /*===========================================//对字符串进行Html编码===========================================*/String.prototype.toHtmlEncode = function(){&&&&&&& var str = &&&&&&& str=str.replace(/&/g,"&");&&&&&&& str=str.replace(/&/g,"&");&&&&&&& str=str.replace(/&/g,"&");&&&&&&& str=str.replace(//'/g,"&");&&&&&&& str=str.replace(//"/g,"&");&&&&&&& str=str.replace(//n/g,"&br&");&&&&&&& str=str.replace(// /g,"&");&&&&&&& str=str.replace(//t/g,"&&&&"); &&&&&&&} /*===========================================//转换成日期===========================================*/String.prototype.toDate = function(){&&&&&&& try&&&&&&& {&&&&&&&&&&&&&&& return new Date(this.replace(/-/g, "//"));&&&&&&& }&&&&&&& catch(e)&&&&&&& {&&&&&&&&&&&&&&&&&&&&&& }} & & & 1.Asc(x),Chr(x):转换字符,字符码 2。Filter:搜寻字符串数组中的特定字符串 格式:v=filter(x,s[,include[,compare]]) 实例: Dim x()={"kjwang","wangkj","peter"} Dim v v=filter(x,"kj") '结果v(0)="kjwang",v(1)="wangkj" v=filter(x,"kj",false) '结果v(0)="peter" v=filter(x,"kj",true,vbTextCompare) '不分大小写搜寻 3.InStr:寻找字符串位置(InstrRev:倒过来寻找字符串) 格式: v=instr(x,y) '从x字符串第1个字符起找出y字符串出现的位置 v=instr(n,x,y) '从x字符串第n个字符起找出y字符串出现的位置 格式: v=InstrRev(x,s[,n[,Compare]]) 4。Join:将字符串连接 格式:v=join(x[,d])’d为分隔字符 5。Len(x):计算字符串x的长度 格式:v=len(x) 6.Left(x,n):返回字符串x左边n个字符(对应Right(x,n)) 7。Mid:读取字符串x中间的字符 格式:v=mid(x,n,m) 8。LTrim(x),RTim(x),Trim(x)去空白字符 9.Replace:字符串取代 格式:v=Replace(x,s,r) 实例:x="i saw a saw a saw" v=replace(x,"saw","so") 'v="i so a so a so" 10.Split:字符串分割 格式:v=split(s[,d]) 实例:v=split("vb.net,iis6.0,asp.net",",") '结果v(0)="vb.net",v(1)="iis6.0",v(2)="asp.net" 11.StrReverse:反转字符串 实例:v=strreverse("kjwang") 'v="gnawjk" 12.UCase(x),LCase(x):变换英文字母的大小写 实例:x="hello,VB中文!" v=UCase(x) 'v="HELLO,VB中文!" 1.取出日期时间 -1)DateValue(x),TimeValue(x) 格式:v=DateValue(x) :取出的“日期”部分    v=timevalue(x) '类上 -2)Year(x),Month(x),Day(x) 格式:v=Year(x)    v=Month(x)    v=Day(x)    Hour(x),Minute(x),Second(x):取出时,分,秒 -3)DateSerial(Y,M,D):合并年、月、日成为日期 实例:Dim v v=DateSerial() 'v=    TimeSerial(H,M,S):合并时、分、秒成为时间 2.Now:读取系统日期时间 格式:v=now 3.Timer:从凌晨12:00:00AM起所经过的秒数 格式:v=timer 4.DatePart(p,x):取出年、月、日等各部分的数值 实例:Dim X=#2/10/:30# v=DatePart("yyyy",X) 'v=1996年 v=DatePart("m",X) 'v=2月 v=DatePart("d",X) 'v=10日 v=DatePart("h",X) 'v=16时 v=DatePart("n",X) 'v=45分 v=DatePart("s",X) 'v=30秒 v=DatePart("q",X) 'v=1季(第一季,春季) v=DatePart("y",X) 'v=41天(1996年的第41天) v=DatePart("ww",X) 'v=6周(1996年的第6周) v=DatePart("w",X) 'v=7(第6周的第7天,即星期六) 5。DateAdd(p,n,x):加减若干时间后的新日期时间 格式:v=DateAdd(p,n,x) 'p值同上如:"yyyy"、"m"等 实例:Dim x=#1/31/:30# v=dateadd("yyyy",-3,x) '减3年,v= 16:45:30 6.DateDiff(p,x1,x2):计算两日期时间的差值 'p值同上 实例:dim x1=#12/31/:30# x2=#2/10/:50# v=datediff("yyyy",x1,x2) 'v=1年 7。FormatDateTime:日期时间的格式化 格式:v=formatdateyime(x[,日期格式]) 日期格式值:DateFormat.GeneralDate 、 DateFormat.LongDate、 DateFotmat.ShortDate、DateFormat.LongTime、DateFormat.ShortTime 8.MonthName:返回月份名称 实例:v=monthname(5) 'v="五月" 9.WeekDayName:返回星期名称 ’用法同8.转自: http://blog.csdn.net/tt/article/details/3999102
阅读(3223)|
用微信&&“扫一扫”
将文章分享到朋友圈。
用易信&&“扫一扫”
将文章分享到朋友圈。
历史上的今天
loftPermalink:'',
id:'fks_083067',
blogTitle:'JS- 操作字符串',
blogAbstract:' Js字符串操作函数大全
虽 然 JavaScript 有很多用处,但是处理字符串是其中最流行的一个。下面让我们深入地分析一下使用
JavaScript 操作字符串。在 JavaScript 中, String 是对象。 String
对象并不是以字符数组的方式存储的,所以我们必须使用内建函数来操纵它们的值。这些内建函数提供了不同的方法来访问字符串变量的内容。下面我们详细看一下
这些函数。 包罗万象
操作字符串的值是一般的开发人员必须面临的家常便饭。操作字符串的具体方式有很多,比如说从一个字符串是提取出一部分内容来,或者确定一个字符串是否包含一个特定的字符。下面的',
blogTag:'js,字符串',
blogUrl:'blog/static/',
isPublished:1,
istop:false,
modifyTime:0,
publishTime:9,
permalink:'blog/static/',
commentCount:0,
mainCommentCount:0,
recommendCount:0,
bsrk:-100,
publisherId:0,
recomBlogHome:false,
currentRecomBlog:false,
attachmentsFileIds:[],
groupInfo:{},
friendstatus:'none',
followstatus:'unFollow',
pubSucc:'',
visitorProvince:'',
visitorCity:'',
visitorNewUser:false,
postAddInfo:{},
mset:'000',
remindgoodnightblog:false,
isBlackVisitor:false,
isShowYodaoAd:false,
hostIntro:'',
hmcon:'1',
selfRecomBlogCount:'0',
lofter_single:''
{list a as x}
{if x.moveFrom=='wap'}
{elseif x.moveFrom=='iphone'}
{elseif x.moveFrom=='android'}
{elseif x.moveFrom=='mobile'}
${a.selfIntro|escape}{if great260}${suplement}{/if}
{list a as x}
推荐过这篇日志的人:
{list a as x}
{if !!b&&b.length>0}
他们还推荐了:
{list b as y}
转载记录:
{list d as x}
{list a as x}
{list a as x}
{list a as x}
{list a as x}
{if x_index>4}{break}{/if}
${fn2(x.publishTime,'yyyy-MM-dd HH:mm:ss')}
{list a as x}
{if !!(blogDetail.preBlogPermalink)}
{if !!(blogDetail.nextBlogPermalink)}
{list a as x}
{if defined('newslist')&&newslist.length>0}
{list newslist as x}
{if x_index>7}{break}{/if}
{list a as x}
{var first_option =}
{list x.voteDetailList as voteToOption}
{if voteToOption==1}
{if first_option==false},{/if}&&“${b[voteToOption_index]}”&&
{if (x.role!="-1") },“我是${c[x.role]}”&&{/if}
&&&&&&&&${fn1(x.voteTime)}
{if x.userName==''}{/if}
网易公司版权所有&&
{list x.l as y}
{if defined('wl')}
{list wl as x}{/list}}

我要回帖

更多关于 去除字符串中的空格 的文章

更多推荐

版权声明:文章内容来源于网络,版权归原作者所有,如有侵权请点击这里与我们联系,我们将及时删除。

点击添加站长微信