DevExpress完成TreeList節點互斥的辦法。本站提示廣大學習愛好者:(DevExpress完成TreeList節點互斥的辦法)文章只能為提供參考,不一定能成為您想要的結果。以下是DevExpress完成TreeList節點互斥的辦法正文
代碼異常適用,這裡就不錯空話,直接送上
重要功效是完成斷定字符串能否包括漢字 而且調換成ASCLL
private static String regEx = "[\\u4e00-\\u9fa5]"; /** * 斷定字符串能否包括漢字 而且調換成ASCLL * * @param str_para * @return str_result */ private static String isChinese_WordStr( String str_para ) { Pattern p = Pattern.compile( regEx ); String str_result = str_para; String str_0 = ""; String str_1 = ""; String str_data[] = null; String str_return_reslut = ""; if ( str_result != null && str_result.trim().length() > 0 ) { try { str_data = str_result.split( "" ); for ( int i = 0; i < str_data.length; i++ ) { Matcher m = p.matcher( str_data[i] ); /* L.d(str_data[i]); */ int count = 0; if ( m.find() ) { count++; str_result = m.group( 0 ); byte[] b = str_result.getBytes( "GBK" ); str_0 = Integer.toHexString( b[0] ); str_1 = Integer.toHexString( b[1] ); str_return_reslut = str_return_reslut + "/" + conver10( str_0 ) + conver10( str_1 ) + "/"; } else { str_return_reslut = str_return_reslut + str_data[i]; } } } catch ( NumberFormatException e ) { e.printStackTrace(); } catch ( UnsupportedEncodingException e ) { e.printStackTrace(); } } else { return(str_return_reslut); } return(str_return_reslut); } /* 字符串轉換十進制 */ public static int conver10( String str_0 ) { return(Integer.parseInt( str_0.substring( str_0.length() - 2, str_0.length() ), 16 ) ); }
我們來看個略微簡略些的代碼,一些需求不高的處所可以用到
import java.util.regex.Matcher; import java.util.regex.Pattern; public class demo { static String regEx = "[\u4e00-\u9fa5]"; static Pattern pat = Pattern.compile(regEx); public static void main(String[] args) { String input = "Hell world!"; System.out.println(isContainsChinese(input)); input = "hello world"; System.out.println(isContainsChinese(input)); } public static boolean isContainsChinese(String str) { Matcher matcher = pat.matcher(str); boolean flg = false; if (matcher.find()) { flg = true; } return flg; }
最初我們附上各類字符的unicode編碼的規模:
* 漢字:[0x4e00,0x9fa5](或十進制[19968,40869])
* 數字:[0x30,0x39](或十進制[48, 57])
*小寫字母:[0x61,0x7a](或十進制[97, 122])
* 年夜寫字母:[0x41,0x5a](或十進制[65, 90])