トップ 差分 一覧 ping ソース 検索 ヘルプ PDF RSS ログイン

Java ASCII文字列かの判定



目次



記事一覧

キーワード

Java ASCII文字列かの判定

[Java][正規表現]


 ASCII文字のみから構成されるか確認

if (str.matches("\\p{ASCII}*")) {
    System.out.println("Ascii charcter only.");
}

 ASCII文字以外が含まれているか確認

if (str.matches("^.*[^\\p{ASCII}].*")) {
    System.out.println("Not Ascii charcter conatins.");
}



YAGI Hiroto (piroto@a-net.email.ne.jp)
twitter http://twitter.com/pppiroto

Copyright© 矢木 浩人 All Rights Reserved.