dimanche 19 juillet 2015

Look for a certain String inside another and count how many times it appears

I am trying to search for a string inside a file content which I got into a String.

I've tried to use Pattern() and Matcher() but it didn't work.

                Pattern p = Pattern.compile("(</machine>)");
                Matcher m = p.matcher(text);
                    while(m.find())//if the text "(</machine>)" was found, enter
                    {
                        Counter++;
                    }

Aucun commentaire:

Enregistrer un commentaire