/**
*版权只属于未来客
*/
import java.util.regex.Pattern;
/**
* @since 2008-05-10
* @author 未来客
* @version 1.0
*/
public class StrTest {

public StrTest(){

}
/**
* @desc 判断是否全是字母
* @param str
* @return
*/
public boolean letterMatch(String str){
if(Pattern.matches("[a-zA-Z]*",str)){
return true;
}
else{
return false;
}
}
/**
* @desc 判断是否全是数字
* @param str
* @return
*/
public boolean numberMatch(String str){
if(Pattern.matches("[0-9]*",str)){
return true;
}
else{
return false;
}
}
/**
* @desc 判断不包含某些字符
* @param str
* @return
*/
public boolean containLetterMatch(String str){
if(Pattern.matches("[a-zA-Z0-9&&[^bc]]*",str)){
return true;
}
else{
return false;
}
}
public static void main(String[] args) {
// TODO Auto-generated method stub
StrTest test=new StrTest();
System.out.println(test.letterMatch("adfdsafjksdafljsadklf"));
System.out.println(test.numberMatch("3255325235235252353252"));
System.out.println(test.containLetterMatch("sddsfgdfsZZFS5465464654FDS"));
}

}
评论
cris_jxg 2008-05-12   回复
if(Pattern.matches("[a-zA-Z]*",str)){
return true;
}
else{
return false;
}
垃圾代码

java正则不好用的说,或操作总是抛出stackflowexception异常
发表评论

您还没有登录,请登录后发表评论

未来客
搜索本博客
博客分类
最近加入圈子
最新评论