java如何验证正负整数11位,小数6位?正则表达式可以吗
4个回答
展开全部
java验证正负整数11位,小数6位,可以使用正则表达式进行匹配,如下代码:
String str = "^[0-9]{1,11}+(.[0-9]{1,6})?$";//匹配整数11位,小数6位的正则表达式
String value = "123456789.12345678";
if(value.matches(str)){
System.out.println("匹配");
}else {
System.out.println("不匹配");
}
2014-11-02
展开全部
如下:
public static String do_post(String url, List<NameValuePair> name_value_pair) throws IOException {
String body = "{}";
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpPost httpost = new HttpPost(url);
httpost.setEntity(new UrlEncodedFormEntity(name_value_pair, StandardCharsets.UTF_8));
HttpResponse response = httpclient.execute(httpost);
HttpEntity entity = response.getEntity();
body = EntityUtils.toString(entity);
} finally {
httpclient.getConnectionManager().shutdown();
}
return body;
}
public static String do_get(String url) throws ClientProtocolException, IOException {
String body = "{}";
DefaultHttpClient httpclient = new DefaultHttpClient();
try {
HttpGet httpget = new HttpGet(url);
HttpResponse response = httpclient.execute(httpget);
HttpEntity entity = response.getEntity();
body = EntityUtils.toString(entity);
} finally {
httpclient.getConnectionManager().shutdown();
}
return body;
}
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
2015-11-10
展开全部
String str = "^[+-][0-9]{1,11}+(.[0-9]{1,6})?$"; 刚试一下 这个就可以了
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
展开全部
String reg = "^[\\+\\-]?[1-9]\\d{10}\\.\\d{6}$";
本回答被提问者和网友采纳
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询