|
马上注册,结交更多好友,享用更多功能,让你轻松玩转社区。
您需要 登录 才可以下载或查看,没有账号?注册
x
发信人: ioly (anguls), 信区: Java
标 题: Re: String问题!
发信站: BBS 水木清华站 (Mon May 27 22:48:47 2002)
jdk1.4的新特性
- import java.util.regex.Pattern;
- import java.util.regex.Matcher;
- public class NumberOnly{
- public static void main(String[] args){
- Pattern p = Pattern.compile("^\\d+$");
- String[] test_list = {
- "",
- "12asDFasdf",
- "#$%$#ASdfasdf1023",
- "测试字符串",
- "\r\n\t1231231",
- "1231231",
- null,
- };
- for(int i = 0, len = test_list.length;i < len;i++){
- System.out.println(""" + test_list[i] + "" is number only? "
- + p.matcher(test_list[i]).matches());
- }
- }
- }
复制代码
【 在 worldeye (人狂) 的大作中提到: 】
: 如何判断,一个输入的String是数字,不是其他字符
: 在Jsp提交表单中使用的! |
|