以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 如何提取数字? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=100866) |
-- 作者:有点辣 -- 发布时间:2017/5/19 21:21:00 -- 如何提取数字? 一个字符串里有汉字和数字,例如 面霸120 如何把里面的数字120提取出来?
|
-- 作者:有点蓝 -- 发布时间:2017/5/19 21:35:00 -- Dim s As String="面霸120" Dim p As String = "[^\\d+]" Dim r As New System.Text.RegularExpressions.Regex(p) Dim str = r.replace(s,"") Output.Show(str)
|
-- 作者:wyz20130512 -- 发布时间:2017/5/19 21:41:00 -- Dim s1 As String = "面霸120" Dim s2 As String For i As Integer = 0 To s1.Length - 1 If Char.IsDigit(s1.Chars(i)) Then s2 = s2 + s1.Chars(i) End If Next Output.Show(s2)
|