判断是否为代码名称,只能包含字母,数字或下划线 @param s @return
(String s)
| 608 | * @return |
| 609 | */ |
| 610 | public static boolean isName(String s) { |
| 611 | if (s == null || s.isEmpty()) { |
| 612 | return false; |
| 613 | } |
| 614 | |
| 615 | String first = s.substring(0, 1); |
| 616 | if ("_".equals(first) == false && PATTERN_ALPHA.matcher(first).matches() == false) { |
| 617 | return false; |
| 618 | } |
| 619 | |
| 620 | return s.length() <= 1 ? true : PATTERN_NAME.matcher(s.substring(1)).matches(); |
| 621 | } |
| 622 | /**判断是否为首字母大写的代码名称 |
| 623 | * @param s |
| 624 | * @return |
no test coverage detected