判断字符串是否仅为数字/首字符是否为字母/汉字
来源:互联网 发布:手机数据流量改dns 编辑:程序博客网 时间:2024/06/12 05:58
// 判断字符串是否仅为数字: public static boolean isNumeric(String str) { Pattern pattern = Pattern.compile("[0-9]*"); return pattern.matcher(str).matches(); } // 判断一个字符串的首字符是否为字母 public static boolean test(String s) { char c = s.charAt(0); int i = (int) c; if ((i >= 65 && i <= 90) || (i >= 97 && i <= 122)) { return true; } else { return false; } } // 判断是否为汉字 public static boolean vd(String str) { char[] chars = str.toCharArray(); boolean isGB2312 = false; for (int i = 0; i < chars.length; i++) { byte[] bytes = ("" + chars[i]).getBytes(); if (bytes.length == 2) { int[] ints = new int[2]; ints[0] = bytes[0] & 0xff; ints[1] = bytes[1] & 0xff; if (ints[0] >= 0x81 && ints[0] <= 0xFE && ints[1] >= 0x40 && ints[1] <= 0xFE) { isGB2312 = true; break; } } } return isGB2312; } // 判断是否为汉字 public static boolean isChineseChar(String str) { boolean temp = false; Pattern p = Pattern.compile("[\u4e00-\u9fa5]"); Matcher m = p.matcher(str); if (m.find()) { temp = true; } return temp; }
0 0
- 判断字符串是否仅为数字/首字符是否为字母/汉字
- 判断字符串是否为数字&&判断字符串是否为字母&&判断子字符串是否为汉字
- ios 判断字符串首字符是否为字母
- 判断录入是否满足字母数字下划线和首字符为字母的要求
- 判断录入是否满足字母数字下划线和首字符为字母的要求 .
- 判断字符串中是否仅包含字母数字和汉字
- 判断字符串中是否仅包含字母数字和汉字
- 判断字符串是否为数字、中文、字母
- 判断是string 是否为数字 是否为字母 是否为汉字
- 判断录入是否满足字母数字下划线和首字符为字母的要求(正则表达式、自定义方法)
- 判断字符串是否为汉字
- c#判断字符串是否全部为数字和字母
- java判断字符串是否为数字或中文或字母
- java判断字符串是否为数字或中文或字母
- java判断字符串是否为数字或中文或字母
- 判断字符串是否为数字且至少包含一位字母
- 判断字符串是否为数字或中文或字母
- android 判断字符串是否为数字或中文或字母
- CODE[VS]3269 混合背包 (背包DP模板集合)
- 判断是否为移动端运行环境
- SurfaceView及Surface分析
- Retrofit2的简单用法(一)
- mysql 的FOUND_ROWS()
- 判断字符串是否仅为数字/首字符是否为字母/汉字
- 面向对象的七大原则
- mfc添加可停靠隐藏等功能的侧边栏
- Spring实战- Aop 使用注解引入新功能(六)
- Java中的Runnable、Callable、Future、FutureTask的区别
- JZOJ4848 永恒的契约
- 静态库制作使用示例
- JavaScript Math对象
- 强制将 SSH 的host key type由 ECDSA替换为RSA