File tree Expand file tree Collapse file tree
main/java/com/blankj/utilcode/util
test/java/com/blankj/utilcode/util Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -67,7 +67,7 @@ class Config {
6767 leakcanary_android_no_op : new DepConfig (" com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version " ),
6868 leakcanary_support_fragment : new DepConfig (" com.squareup.leakcanary:leakcanary-support-fragment:$leakcanary_version " ),
6969
70- free_proguard : new DepConfig (" com.blankj:free-proguard:1.0.1 " ),
70+ free_proguard : new DepConfig (" com.blankj:free-proguard:1.0.2 " ),
7171 swipe_panel : new DepConfig (" com.blankj:swipe-panel:1.2" ),
7272
7373 gson : new DepConfig (" com.google.code.gson:gson:2.8.6" ),
Original file line number Diff line number Diff line change @@ -47,7 +47,33 @@ public static boolean isMobileSimple(final CharSequence input) {
4747 * @return {@code true}: yes<br>{@code false}: no
4848 */
4949 public static boolean isMobileExact (final CharSequence input ) {
50- return isMatch (RegexConstants .REGEX_MOBILE_EXACT , input );
50+ return isMobileExact (input , null );
51+ }
52+
53+ /**
54+ * Return whether input matches regex of exact mobile.
55+ *
56+ * @param input The input.
57+ * @param newSegments The new segments of mobile number.
58+ * @return {@code true}: yes<br>{@code false}: no
59+ */
60+ public static boolean isMobileExact (final CharSequence input , List <String > newSegments ) {
61+ boolean match = isMatch (RegexConstants .REGEX_MOBILE_EXACT , input );
62+ if (match ) return true ;
63+ if (newSegments == null ) return false ;
64+ if (input == null || input .length () != 11 ) return false ;
65+ String content = input .toString ();
66+ for (char c : content .toCharArray ()) {
67+ if (!Character .isDigit (c )) {
68+ return false ;
69+ }
70+ }
71+ for (String newSegment : newSegments ) {
72+ if (content .startsWith (newSegment )) {
73+ return true ;
74+ }
75+ }
76+ return false ;
5177 }
5278
5379 /**
Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ public void isMobileSimple() {
2626 public void isMobileExact () {
2727 assertFalse (RegexUtils .isMobileExact ("11111111111" ));
2828 assertTrue (RegexUtils .isMobileExact ("13888880000" ));
29+ assertTrue (RegexUtils .isMobileExact ("12088880000" , CollectionUtils .newArrayList ("120" )));
2930 }
3031
3132 @ Test
You can’t perform that action at this time.
0 commit comments