簡單的問題可能有一個簡單的答案,但我目前的解決方案看起來很可怕。 local list = {'?', '!', '@', ... etc)
for i=1, #list do
if string.match(string, strf("%%%s+", list[i])) then
-- string contains characters that are not alp
我的問題是,我猜很簡單: 如何在Java中將字節轉換爲字母數字字符數組(字符串)? 我試過,但它給了我回來的NetBeans的錯誤: byte[] b = "test".getBytes("ASCII");
String test = new String(b,"ASCII");
更新: 其實我用這個代碼: byte[] b = "test".getBytes("ASCII");
我正在尋找一個優雅的方式,最好是一個短linq表達式來計算給定字符串包含多少個字母數字字符。 的「無聊」的方式我現在做的是這樣的: int num = 0;
for (int i = 0; i < password.Length; i++)
{
if (!char.IsLetterOrDigit(password, i))
{
num++;
}
}