以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- 怎样用正则取出字符串中所有数值? (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=48578) |
-- 作者:苍风霁月 -- 发布时间:2014/4/1 10:56:00 -- 怎样用正则取出字符串中所有数值? 如:abc345345sdagf675.654OK,取出其中两个数据? [此贴子已经被作者于2014-4-1 10:56:25编辑过]
|
-- 作者:Bin -- 发布时间:2014/4/1 11:03:00 -- Dim str As String = "abc345345sdagf675.654OK" Dim mh As System.Text.RegularExpressions.match mh=System.Text.RegularExpressions.Regex.match(str,"[0-9.]+") output.show(mh.Tostring()) Do While mh .ToString() <> "" mh = mh .NextMatch() If mh .ToString() <> "" Then output.show(mh.Tostring()) End If Loop |
-- 作者:lsy -- 发布时间:2014/4/1 13:40:00 -- Dim str As String = "abc345345sdagf675.654OK" For Each s As String In str If Char.IsDigit(s) = False AndAlso s <> "." Then str = str.Replace(s,"|") End If Next For Each s As String In str.Split("|") If s > "" Then Output.Show(s) End If Next |