问题描述
我有一个字符串,其中包含两个需要提取的浮点值。 我尝试过了
String latlong=xbeeMessage.getDataString();
Pattern pat=Pattern.compile("(?<=lat=)\\d+");
Pattern pat1=Pattern.compile("(?<=long=)\\d+");
Matcher m=pat.matcher(latlong);
Matcher m1=pat1.matcher(latlong);
if(m.find())
{
float lat=Float.parseFloat(m.group());
float lon=Float.parseFloat(m1.group());
}
这在语法上是正确的,并且没有引发错误,但这是行不通的。 字符串latlong的格式为
lat = xx.xxxx&long = yy.yyyyy 小数点后的位数可能不一定总是相同。
解决方法
暂无找到可以解决该程序问题的有效方法,小编努力寻找整理中!
如果你已经找到好的解决方法,欢迎将解决方案带上本链接一起发送给小编。
小编邮箱:dio#foxmail.com (将#修改为@)