我没有在logcat中获得任何输出我已经尝试过Log.v(" dd",matcher.group(0)),Log.v(" dd",matcher。 group(1))和Log.v(" dd",matcher.toString());我不知道为什么我要改变什么。我该如何让匹配器选择整个字符串" thingamabob"
try {
String ss="thingamabob";
Pattern pattern = Pattern.compile(".*");
Matcher matcher = pattern.matcher(ss);
Log.v("dd",matcher.group());
}
catch(Exception e){ }
答案 0 :(得分:0)
试试这段代码..
try{
String ss="thingamabob";
Pattern pattern = Pattern.compile(".*");
Matcher matcher = pattern.matcher(ss);
matcher.matches();
Log.v("dd",matcher.toMatchResult().group());
}
catch(Exception e){
}