Here you can find the source of startsWithCapLettersEndsWithDigits(String text)
Parameter | Description |
---|---|
text | String to parse |
public static boolean startsWithCapLettersEndsWithDigits(String text)
//package com.java2s; public class Main { /**/*from w ww. jav a 2s . c om*/ * Determine if a string starts with capital letter(s) and ends with * digit(s). * * @param text String to parse * * @return true if name starts with capital letter(s) and ends with * digit(s), false otherwise */ public static boolean startsWithCapLettersEndsWithDigits(String text) { boolean result = false; if (!isNullOrEmpty(text, true)) { char[] cs = text.toCharArray(); int j = 0; while ((j < cs.length) && (Character.isUpperCase(cs[j]))) { j++; } if ((j == 0) || (j == cs.length)) { result = false; } else { result = digitsOnly(text.substring(j)); } } return result; } /** * Determines if a String is null or empty * * @param text text to examine * @param trim whether to trim the text before testing it's content * * @return true if text is null or empty, false otherwise */ public static boolean isNullOrEmpty(String text, boolean trim) { boolean result = true; if (text != null) { String data = text; if (trim) { data = data.trim(); } if (data.length() > 0) { result = false; } } return result; } /** * Determine if a string contains digit(s) only * * @param text String to parse * * @return true if text contains only digit(s), false otherwise */ public static boolean digitsOnly(String text) { boolean result = true; if (isNullOrEmpty(text, true)) { result = false; } else { char[] c = text.toCharArray(); int j = 0; while ((result) && (j < c.length)) { if (!Character.isDigit(c[j])) { result = false; } ++j; } } return result; } }