以文本方式查看主题 - Foxtable(狐表) (http://foxtable.net/bbs/index.asp) -- 专家坐堂 (http://foxtable.net/bbs/list.asp?boardid=2) ---- [求助]正则表达式提取信息 (http://foxtable.net/bbs/dispbbs.asp?boardid=2&id=161463) |
-- 作者:zto001 -- 发布时间:2021/3/18 11:10:00 -- [求助]正则表达式提取信息 Dim s As String = "大叔大婶多伟1564585421大 打算的15645854214采访人 15sdf6s54df6fs544防守打法 发送到" Dim p As String = "(13[0-9]|14[0-9]|15[0-9]|166|17[0-9]|18[0-9]|19[8|9])\\d{8}" Dim rgx = new System.Text.RegularExpressions.Regex(p, System.Text.RegularExpressions.RegexOptions.IgnoreCase) For Each match As System.Text.RegularExpressions.Match In rgx.Matches(s) Output.Show(match.Value ) Next 这样可以提取电话号码。我如果需要提取金额怎么用不了? Dim s As String="收到现金2.22元" Dim p As String = "^([1-9]\\d{0,9}|0)(\\.\\d{1,2})?$" Dim rgx = new System.Text.RegularExpressions.Regex(p, System.Text.RegularExpressions.RegexOptions.IgnoreCase) For Each m As object In rgx.Matches(s) Output.Show(m.value) Next |
-- 作者:有点蓝 -- 发布时间:2021/3/18 11:15:00 -- Dim p As String = "\\d+[\\.]?\\d*" |