随笔分类 - 常用代码
摘要:1、过滤所有数字 String regEx="[0-9]"; Pattern p=Pattern.compile(regEx); Matcher m=p.matcher(str); m.replaceAll("").trim(); 2、过滤所有非数字字符 String regEx="[^0-9]";
阅读全文
摘要:char 与int 1、int 转换成char: int n = 1; char ch = (char)(n + '0'); 这样打印出来ch的值为1; 不过需要注意(因为char只有一个字节),此处的n只能是0-9之间的字符 2、char转换成Int: char ch = '9'; int n =
阅读全文