以文本方式查看主题 - Foxtable(狐表) (http://foxtable.com/bbs/index.asp) -- 专家坐堂 (http://foxtable.com/bbs/list.asp?boardid=2) ---- 判断一个字符串是否在1000~1000000000之间,必须全部是数字,怎么改代码? (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=106506) |
-- 作者:zhangjian222200 -- 发布时间:2017/9/10 18:32:00 -- 判断一个字符串是否在1000~1000000000之间,必须全部是数字,怎么改代码? Dim pattern As String = "^[1][345789][0-9]{9}$" Dim txt as string= “13512341234” Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) If rgx.isMatch(txt) = False Then e.WriteString("请输入正确的手机号!") Return "" End If 上面是已经能够正确使用的代码,现在想改为: 判断一个字符串是否在1000~1000000000之间,必须全部是数字,怎么改代码? Dim pattern As String = "^[1][345789][0-9]{9}$" Dim txt as string= “1355de35” Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) If rgx.isMatch(txt) = False Then e.WriteString("请输入正确的编号!") Return "" End If [此贴子已经被作者于2017/9/10 18:38:56编辑过]
|
-- 作者:有点甜 -- 发布时间:2017/9/10 20:52:00 -- Dim pattern As String = "^[0-9]{4,9}|1000000000$" Dim txt As String= "1000000000" Dim rgx = new System.Text.RegularExpressions.Regex(pattern, System.Text.RegularExpressions.RegexOptions.IgnoreCase) If rgx.isMatch(txt) = False Then msgbox("请输入正确的编号!") Return "" End If |