Skip to content

Commit 4d3d5cd

Browse files
author
Blankj
committed
see 11/30 log
1 parent 00b634c commit 4d3d5cd

3 files changed

Lines changed: 29 additions & 2 deletions

File tree

buildSrc/src/main/groovy/Config.groovy

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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"),

lib/utilcode/src/main/java/com/blankj/utilcode/util/RegexUtils.java

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff 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
/**

lib/utilcode/src/test/java/com/blankj/utilcode/util/RegexUtilsTest.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff 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

0 commit comments

Comments
 (0)