Android搜索框输入过滤特殊字符

来源:互联网 发布:html5数据统计 编辑:程序博客网 时间:2024/05/02 04:54
使用方法
  String str = stringFilter(editable);//过滤特殊字符

//过滤特殊字符
publicString stringFilter(String str)throwsPatternSyntaxException{
    String regEx ="[/\\:*?<>|,,\"\n\t]";
    Pattern p = Pattern.compile(regEx);
    Matcher m = p.matcher(str);
   returnm.replaceAll("");

}



0 0
原创粉丝点击