count Words in a string with regex - Android java.util.regex

Android examples for java.util.regex:Word Count

Description

count Words in a string with regex

Demo Code


public class Main{

    public static int countWords(String s) {
        String arr[] = s.split("[\\s,;()]+");

        return arr.length;
    }//from  www  .  ja  v a  2 s  . com

}

Related Tutorials