//提取数字 public String numberintercept(String num) { String phoneString =num; Pattern pattern = Pattern.compile("[^0-9]"); Matcher matcher = pattern.matcher(phoneString); String all = matcher.replaceAll(""); return Pattern.compile("[^0-9]").matcher(phoneString).replaceAll(""); }
<span style="white-space:pre"> </span>//提取汉字 public String intercept(String str) { String regex = "[\u4E00-\u9FA5]+";// [//u4E00-//u9FFF]为汉字 Pattern pattern = Pattern.compile(regex); Matcher matcher = pattern.matcher(str); StringBuffer sb = new StringBuffer(); while (matcher.find()) { sb.append(matcher.group()); } String content = sb.toString(); return content; }
<span style="white-space:pre"> </span>//过滤不想要的特殊符号 public String con (String str) { String regEx="[`~!@#$%^&*()+=|{}:;\\[\\].<>/?~!@#¥%……&*()——+|{}【】‘;:”“’。,、?]"; Pattern p = Pattern.compile(regEx); Matcher m = p.matcher(str); String url = m.replaceAll("").trim(); return url; }
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。