2
if PassField.Text:match("%a+%d%d+") or PassField.Text:match("%d%d+%a+") then
PWValid = true
else
return 'Error1'
end
這是到目前爲止我的代碼,但它不是太efficent因爲字符串可以像bb1b12,所以我需要檢測如果字符串包含2號的任何地方檢查字符串包含2號
if PassField.Text:match("%a+%d%d+") or PassField.Text:match("%d%d+%a+") then
PWValid = true
else
return 'Error1'
end
這是到目前爲止我的代碼,但它不是太efficent因爲字符串可以像bb1b12,所以我需要檢測如果字符串包含2號的任何地方檢查字符串包含2號
兩個數字是「一些數字,然後一些非數字,然後更多的數字」。你不需要關心字符串中的其他內容。只需使用%d恭維 - %D - 它意味着與原來的完全相反。如果你只想測試字符串是否有效,你也應該使用find
。
str:find("%d+%D+%d+")