while(matcher.find()) - 错误 - 不起作用

While(matcher.find()) - Error - Doesn't Work

我需要排序帮助

我不知道为什么当我有字符串 "3*3"

时它会被 matcher.find() 跳转

代码:

    public void delSin_Cos_Tan()
            {
                o = new ArrayList<>();
                String aDate = "3*3";
                Pattern datePattern = Pattern.compile("((sin|cos|tan|sinh|cosh|tanh|asin|acos|atan)\((.+)\))"); 
//Operat.Sin_Cos_Tan.Patter = ((sin|cos|tan|sinh|cosh|tanh|asin|acos|atan)\((.+)\))
                Matcher matcher = datePattern.matcher(aDate);
                Log.d(TAG,"Sin Startz");
                Log.d(TAG,"Sin " + Aufgabe);
                while (matcher.find());
                {
                    Log.e(TAG,matcher.group(1)); // there is the Error, but withe the String "3*3" an i don't konw why it is jump inside the while  
                    String Gesammt = matcher.group(1);
                    String TYP = matcher.group(2);
                    String Inklammer = matcher.group(3);

                    Log.d(TAG, String.valueOf("------------------------"));
                    Log.d(TAG, Gesammt);
                    Log.d(TAG, Inklammer);
                    Log.d(TAG, TYP);
                    Log.d(TAG, String.valueOf("------------------------"));
               }
            }

我的完全码:http://pastebin.com/jWN1ghfz

你在 while 循环后得到了一个 ;。 这就是为什么你的完整块总是会被执行!

while (matcher.find()); 应该是 while (matcher.find())(没有 ;

因为

while (matcher.find());
{
 //...
}

相同
while (matcher.find()){
;
}

{
 //...
}