dimanche 7 mai 2017

Cant find pattern from String (Android Studio)

I need help. So I Have this String that includes "Tulos: +1" many times in it and I try to find how many times "Tulos: +1" occurs in that String but it does not work. It does not send an error it just does not find it. That toast is just for testing. And it always says that count2 = 0. By the way that query works fine. I think that the problem is caused by that plus sing but I cannot figured it out. :/

count2 = 0;

while(query1.moveToNext()){

            String str2 = query1.getString(0);

            Toast.makeText(kortti.this,
                    str2 + count2, Toast.LENGTH_LONG).show();

            Pattern p2 = Pattern.compile("Tulos: +1");
            Matcher m2 = p2.matcher(str2);
            while (m2.find()){
                count2 +=1;
                System.out.println(count2);
            }

        }

Aucun commentaire:

Enregistrer un commentaire