Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/sharepoint/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
String 检查字符串是否包含2个数字_String_Lua - Fatal编程技术网

String 检查字符串是否包含2个数字

String 检查字符串是否包含2个数字,string,lua,String,Lua,到目前为止,这是我的代码,但效率不太高,因为字符串可能类似于bb1b12,因此我需要检测字符串是否在任何位置包含2个数字两个数字是“一些数字,然后是一些非数字,然后是更多的数字”。您不需要关心字符串中的任何其他内容。只需使用%d个赞美词-%d-它的意思与原文完全相反。另外,如果您只想测试字符串是否有效,您可能应该使用find if PassField.Text:match("%a+%d%d+") or PassField.Text:match("%d%d+%a+") then PWVal

到目前为止,这是我的代码,但效率不太高,因为字符串可能类似于bb1b12,因此我需要检测字符串是否在任何位置包含2个数字

两个数字是“一些数字,然后是一些非数字,然后是更多的数字”。您不需要关心字符串中的任何其他内容。只需使用%d个赞美词-%d-它的意思与原文完全相反。另外,如果您只想测试字符串是否有效,您可能应该使用
find

if PassField.Text:match("%a+%d%d+") or PassField.Text:match("%d%d+%a+") then
    PWValid = true
else
    return 'Error1'
end
str:find("%d+%D+%d+")