【发布时间】:2011-05-17 20:31:43
【问题描述】:
我正在遍历数百个数据条目,其中大部分根据我的规则有效,但在使用条目之前必须过滤一些特殊字符或不需要的空格。
我只希望= 和, 字符可以与数字和字母一起使用。没有其他特殊字符。可以有单个空格,但只能在 , 之后分隔数据。
我在循环中调用过滤器方法:
private String filterText(String textToBeFiltered) {
String filteredText = null;
// Remove all chars apart from = and , with whitespace only allowed
// after the ,
return filteredText;
}
我对正则表达式完全陌生,但一直在寻找教程,希望有任何想法。
谢谢!
弗兰克
【问题讨论】:
标签: java regex string validation filter