Thread Rating:
  • 461 Vote(s) - 2.88 Average
  • 1
  • 2
  • 3
  • 4
  • 5
文字列チェック
09-26-2011, 05:32 PM,
#3
RE: 文字列チェック
バイト数に関してはStringUtilのget-bytesを使用しました。

特殊文字を使わなければこんな感じで判定してます。

Code:
{import * from COM.CURLAP.LIB.LANG}

{let str:String = "11アアaAaA!!\||\\¥"}
{let message:VBox={VBox}}
{for c:char in str do
    || バイト判定
    let bt:int = {StringUtil.get-bytes {String c}}
    let st:String = c & " = "
    || 全角判定
    {if bt == 1 then
        set st = st & "半角,"
     else
        set st = st & "全角,"
    }
    || 数字判定
    {if ((c>='0' and c<='9') or
         (c>='0' and c<='9'))
     then
        set st = st & "数字,"
    }
    || 英字判定
    {if ((c>='A' and c<='Z') or
         (c>='a' and c<='z') or
         (c>='A' and c<='Z') or
         (c>='a' and c<='z'))
     then
        set st = st & "英字,"
     else
        set st = st & "英字以外,"
    }
    set st = st & " " & bt & "バイト"
    {message.add st}

}
{value message}


Messages In This Thread
文字列チェック - by umemura - 09-26-2011, 12:23 PM
RE: 文字列チェック - by onyo - 09-26-2011, 02:00 PM
RE: 文字列チェック - by usami - 09-26-2011, 05:32 PM
RE: 文字列チェック - by umemura - 07-03-2013, 04:16 PM
Forum Jump:


Users browsing this thread:
1 Guest(s)

MyBB SQL Error

MyBB has experienced an internal SQL error and cannot continue.

SQL Error:
1017 - Can't find file: 'mybb_threadviews' (errno: 2)
Query:
INSERT INTO mybb_threadviews (tid) VALUES('285')