如何快速去掉单位只取数字?

phuai007 2011-09-23 02:08:05
233 元/月
比如这个,只取 前面的 这里是233,但不一定是数字,有可能是其他字符
...全文
1486 8 打赏 收藏 转发到动态 举报
写回复
用AI写文章
8 条回复
切换为时间正序
请发表友善的回复…
发表回复
Dogfish 2011-09-24
  • 打赏
  • 举报
回复
楼主用4楼的吧。如果没有别的干扰数字,应该可以的。
猜我是几娃 2011-09-24
  • 打赏
  • 举报
回复
把字符转换成 ASCII 码逐一判断是不是0-9的asc码,也很精确,
xuStanly 2011-09-24
  • 打赏
  • 举报
回复
alert(parseFloat('233 元/月'));
叫我梁大侠 2011-09-23
  • 打赏
  • 举报
回复
楼上都正解~~~~~
zhux2003 2011-09-23
  • 打赏
  • 举报
回复
用正则表达式可以解决
<%
str="233 元/月"
str=strFilter(str)
function strFilter(strsource)
Set obRegexp=New RegExp
obRegexp.IgnoreCase=True
obRegexp.Global=True
obRegexp.Pattern="[^0-9]*"
strsource=obRegexp.Replace(strsource,"")
Set obRegexp = Nothing
strFilter=strsource
end function
%>
001007009 2011-09-23
  • 打赏
  • 举报
回复

function getNum(str)
Dim re : set re = new RegExp
re.Pattern = "[^\d]*"
re.IgnoreCase = True
re.Global = True
getNum = re.replace(str,"")
end function
str = "233 元/月"
response.write getNum(str)

楼主试试
phuai007 2011-09-23
  • 打赏
  • 举报
回复
自己写出来了


'编辑的时候去掉单位
Function dell_dw(str)
str1=split(str," ")
dell_dw=str1(0)
End function
三石-gary 2011-09-23
  • 打赏
  • 举报
回复
substring()截取字符串。。。

28,404

社区成员

发帖
与我相关
我的任务
社区描述
ASP即Active Server Pages,是Microsoft公司开发的服务器端脚本环境。
社区管理员
  • ASP
  • 无·法
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧