中文字幕在线观看,亚洲а∨天堂久久精品9966,亚洲成a人片在线观看你懂的,亚洲av成人片无码网站,亚洲国产精品无码久久久五月天

Java統(tǒng)計(jì)字符串中漢字,英文,數(shù)字,特殊符號個(gè)數(shù)

2018-07-20    來源:open-open

容器云強(qiáng)勢上線!快速搭建集群,上萬Linux鏡像隨意使用
package wzs.arithmetics;
 
/**
 * 分別統(tǒng)計(jì)出其中字符串中漢字,英文字母,數(shù)字,其他字符數(shù)量
 * @author wWX154783
 *
 */
public class Test_wzs7
{
    public static void main(String[] args)
    {
        String str = "a12中國3@b&4語*言3c";
 
        String E1 = "[\u4e00-\u9fa5]";// 中文
        String E2 = "[a-zA-Z]";// 英文
        String E3 = "[0-9]";// 數(shù)字
 
        int chineseCount = 0;
        int englishCount = 0;
        int numberCount = 0;
 
        String temp;
        for (int i = 0; i < str.length(); i++)
        {
            temp = String.valueOf(str.charAt(i));
            if (temp.matches(E1))
            {
                chineseCount++;
            }
            if (temp.matches(E2))
            {
                englishCount++;
            }
            if (temp.matches(E3))
            {
                numberCount++;
            }
        }
        System.out.println("漢字?jǐn)?shù):" + chineseCount);
        System.out.println("英文數(shù):" + englishCount);
        System.out.println("數(shù)字?jǐn)?shù):" + numberCount);
        System.out.println("特殊字符:" + (str.length() - (chineseCount + englishCount + numberCount)));
    }
}

標(biāo)簽:

版權(quán)申明:本站文章部分自網(wǎng)絡(luò),如有侵權(quán),請聯(lián)系:west999com@outlook.com
特別注意:本站所有轉(zhuǎn)載文章言論不代表本站觀點(diǎn)!
本站所提供的圖片等素材,版權(quán)歸原作者所有,如需使用,請與原作者聯(lián)系。

上一篇:python通過urllib2提交http post請求

下一篇:Android用Animation實(shí)現(xiàn)圖像的 漸變、縮放、位移、旋轉(zhuǎn)