求pb判断输入[size=12px]的字符串是否符合手机号码段的正则表达式?
比如 我在一个mle_1 中输入了一串字符串:
"13900000,138000,13199999,13200000,136000000"
要求能长度判断 并且 判断是否合法的目前正在使用的手机号段...
match('18000000','^[(134)|(138)|(186)|(180)][0-9][0-9][0-9][0-9][0-9][0-9][0-9][0-9]$') 现在是这样 无法长度判断
------解决方案--------------------
先将字符串split成单个号码,然后再判断
string strTel
string strTelsplit[]
string strCheck
int iLen
int i
strTel = mle_1.text
if isnull(strTel) then return
//分割字符串
kealmethod.StrSplit(strTel, strTelsplit[])
if isnull(strTel) then return
//分割后的数组长度
iLen = upperbound(strTelsplit[])
//判断
for i = 1 to long(iLen)
strCheck = strTelsplit[i]
//长度and合法性判断
//if strCheck不合法 then
//messagebox()
// else continue
// end if
end for
//字符串split成单个号码
public function integer strsplit (string as_parm, ref string as_data[]);
long ll_pos, ll_item
if isnull(as_parm) then
as_parm = ''
end if
if len(as_parm) <= 0 then
return 0
end if
ll_item = 0
//取得逗号在字符串中的位置
ll_pos = pos(as_parm, ',')
do while ll_pos > 0
ll_item ++
//将分割出的号码放入数组
as_data[ll_item] = left(as_parm, ll_pos - 1)
//从元数据中去除以取出的号码
as_parm = mid(as_parm, ll_pos + 1)
ll_pos = pos(as_parm, ',')
loop
ll_item ++
as_data[ll_item] = as_parm
return 1
end function