isMobileExact static method
Return whether input matches regex of exact mobile.
When the static exact regex misses and newSegments is provided, an
11-digit all-ASCII input whose prefix matches any caller-supplied new
carrier segment passes — the regex can age without waiting for a
library release. Empty segments are skipped, so a caller typo cannot
widen the check.
Note: stricter than the Java original this mechanism was absorbed
from — \d is ASCII-only, so fullwidth digits (2) are rejected,
whereas Java's Character.isDigit accepts them.
精确验证是否是手机号;静态正则未命中时,可传 newSegments(新号段
前缀列表)兜底:输入为 11 位纯 ASCII 数字(全角数字拒绝)且命中任一
非空号段前缀即通过;空串号段会被跳过、不参与匹配。
Implementation
static bool isMobileExact(String input, {List<String>? newSegments}) {
if (matches(RegexConstants.REGEX_MOBILE_EXACT, input)) return true;
if (newSegments == null) return false;
if (input.length != 11 || !_elevenDigitsRegExp.hasMatch(input)) {
return false;
}
for (final String newSegment in newSegments) {
if (newSegment.isEmpty) continue;
if (input.startsWith(newSegment)) return true;
}
return false;
}