// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
public class TestLengthOfWord {
    public static int lengthOfWord(String line, int wordno) {
        return line.split("\\W+")[wordno].length();
    }
    public static void main(String[] args) {
        System.out.println(lengthOfWord("aa bbb, ccc dddd", 0));
        System.out.println(lengthOfWord("aa bbb, ccc dddd", 1));
        System.out.println(lengthOfWord("aa bbb, ccc dddd", 2));
        System.out.println(lengthOfWord("aa bbb, ccc dddd", 3));
    }
}
