以下为pb9是哟正则表达式校验字符串的一些示例,搭配使用可以验证密码强度、字符串是否符合需求等
//文本包含一个或多个大写字母
if not Match("232A232" ,"[A-Z]+") then
messagebox('提示','文本不包含一个或多个大写字母,请修改!')
//Return 1
else
messagebox('提示','文本包含一个或多个大写字母!')
end if
//文本包含一个或多个小写字母
if not Match("232a232" ,"[a-z]+") then
messagebox('提示','文本不包含一个或多个小写字母,请修改!')
//Return 1
else
messagebox('提示','文本包含一个或多个小写字母。')
end if
//文本包含任何数字
if not Match("1weqe" ,"[0-9]") then
messagebox('提示','文本包含任何数字,请修改!')
//Return 1
else
messagebox('提示','文本包含数字。')
end if
//文本包含特殊字符
if not Match("#1weqe" ,"[`~!@#$%^&*]") then
messagebox('提示','文本不包含特殊字符,请修改!')
//Return 1
else
messagebox('提示','文本包含特殊字符。')
end if
//强密码(必须包含大小写字母和数字的组合,不可以使用特殊字符,长度在8-10之间)
if not Match("@#we2eAA2" ,"[A-Za-z0-9]+{8,10}") then
messagebox('提示','文本不包含大小写字母和数字的组合,请修改!')
//Return 1
else
messagebox('提示','文本包含大小写字母和数字的组合。')
end if
//全字母判断
if not Match(sle_1.text ,"^[a-zA-Z]+$") then
messagebox('提示','文本不是纯字母组合,请修改!')
//Return 1
else
messagebox('提示','文本是纯字母组合。')
end if