1.
import java.util.regex.Pattern
import java.util.regex.Matcher
程序代码:
public boolean isNumeric(String str)
{
Pattern pattern = Pattern.compile("[0-9]*");
Matcher isNum = pattern.matcher(str);
if( !isNum.matches() )
{
return false;
}
return true;
}
2.
"123".matches("^[0-9]*$");