手机号连号,顺序号验证

package com.demo.test;

public class Test {

	public static void main(String[] args) {
		//手机连号设置
		int mobileCount = 6;
		String[]  mobile = {
				"13511111111","13555555555","13599999999",
				"13512345678","13501234567","13576543210",
				"13587654321","13501234012","13587654376"};
		for(int z = 0; z < mobile.length; z++) {
			//去除相同连号开始
			//相同连号0-9,10种匹配
			for(int i = 0; i <=9; i++) {
				String str = "";
				for(int j = 0; j < mobileCount; j++) {
					str += i;
				}
				mobile[z] = mobile[z].replace(str,"");
			}
			//去除相同连号结束
			//去除升序连号
			//10-连号设置+1为循环总个数
			for(int i = 0; i < 11-mobileCount; i++) {
				String str = "";
				for(int j = 0; j < mobileCount; j++) {
					str += i + j;
				}
				mobile[z] = mobile[z].replace(str,"");
			}
			//去除升序连号
			//去除降序连号
			//10-连号设置+1为循环总个数
			for(int i = 0; i < 11-mobileCount; i++) {
				String str = "";
				for(int j = 0; j < mobileCount; j++) {
					//9为降序起始数值
					str += 9-i-j;
				}
				mobile[z] = mobile[z].replace(str,"");
			}
			//去除降序连号
		}
		
		for(int z = 0; z < mobile.length; z++) {
			System.out.println(mobile[z]);
		}
	}

}

配合手机正则使用:var regName = /^1[3|4|5|8][0-9]\d{8}$/;

可直接用于后台验证手机号或前台js验证手机号

使用环境:

    需用户填写手机号,验证手机号是否为相同连号或升降序连号

    如:

13511111111,13599999999,13501234567,13598765432

手机号连号,顺序号验证,布布扣,bubuko.com

手机号连号,顺序号验证

上一篇:微信扫物上线,全面揭秘扫一扫背后的识物技术!


下一篇:Android 桌面上特定的图标不能被移动和删除