用split按字母分开:

import java.util.*;
public class Main {
    public static void main(String[] args) throws Exception{
        Scanner sc = new Scanner(System.in);
        String s = sc.nextLine();
        String[] v = s.split("[a-z]");
        String r = "";
        for(String i : v){
            if(i.contains(" ")) continue;    //空格也不要
            if(r.length() < i.length()) r = i;
        }
        System.out.println(r);
    }
}