例子:43122345HTHB85532328GNSJ

由于122345是最长的递增自然数,所以最大长度为6

public class Test1 {

    public static void main(String[] args) {

        Scanner scanner = new Scanner(System.in);
        String str = scanner.next();
        if (null == str || 0 == str.length()) {
            System.out.println(0);
        } else {
            String numStr = str.replaceAll("[a-zA-Z]", "-");
            String[] num = numStr.split("-");

            int maxLength = 0;
            for (int i = 0; i < num.length; i++) {
                if (0 == num[i].length()) {
                    continue;
                }

                if (1 == num[i].length()) {
                    maxLength = 1;
                    continue;
                }

                StringBuilder count = new StringBuilder();
                boolean flag = false;
                String number = num[i];
                char[] numbers = number.toCharArray();
                for (int j = numbers.length - 1; j > 0; j--) {
                    if (numbers[j] >= numbers[j - 1]) {
                        count.append(1);
                    } else {
                        count.append(0);
                    }
                }

                String zeroAndOne = count.toString();
                String[] ones = zeroAndOne.split("0");
                for (int k = 0; k < ones.length; k++) {
                    if (ones[k].length() >= maxLength) {
                        maxLength = ones[k].length();
                    }
                }
            }
            System.out.println(maxLength + 1);
        }
    }
}