提交 4d3d5cd2 编写于 作者: B Blankj

see 11/30 log

上级 00b634cf
......@@ -67,7 +67,7 @@ class Config {
leakcanary_android_no_op : new DepConfig("com.squareup.leakcanary:leakcanary-android-no-op:$leakcanary_version"),
leakcanary_support_fragment: new DepConfig("com.squareup.leakcanary:leakcanary-support-fragment:$leakcanary_version"),
free_proguard : new DepConfig("com.blankj:free-proguard:1.0.1"),
free_proguard : new DepConfig("com.blankj:free-proguard:1.0.2"),
swipe_panel : new DepConfig("com.blankj:swipe-panel:1.2"),
gson : new DepConfig("com.google.code.gson:gson:2.8.6"),
......
......@@ -47,7 +47,33 @@ public final class RegexUtils {
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isMobileExact(final CharSequence input) {
return isMatch(RegexConstants.REGEX_MOBILE_EXACT, input);
return isMobileExact(input, null);
}
/**
* Return whether input matches regex of exact mobile.
*
* @param input The input.
* @param newSegments The new segments of mobile number.
* @return {@code true}: yes<br>{@code false}: no
*/
public static boolean isMobileExact(final CharSequence input, List<String> newSegments) {
boolean match = isMatch(RegexConstants.REGEX_MOBILE_EXACT, input);
if (match) return true;
if (newSegments == null) return false;
if (input == null || input.length() != 11) return false;
String content = input.toString();
for (char c : content.toCharArray()) {
if (!Character.isDigit(c)) {
return false;
}
}
for (String newSegment : newSegments) {
if (content.startsWith(newSegment)) {
return true;
}
}
return false;
}
/**
......
......@@ -26,6 +26,7 @@ public class RegexUtilsTest extends BaseTest {
public void isMobileExact() {
assertFalse(RegexUtils.isMobileExact("11111111111"));
assertTrue(RegexUtils.isMobileExact("13888880000"));
assertTrue(RegexUtils.isMobileExact("12088880000", CollectionUtils.newArrayList("120")));
}
@Test
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册