Java tutorial
//package com.java2s; import android.text.TextUtils; import java.util.regex.Pattern; public class Main { public static boolean isCorrectIDCardNumber(String idCardNumber) { return !TextUtils.isEmpty(idCardNumber) && Pattern.matches("(\\d{14}[0-9a-zA-Z])|(\\d{17}[0-9a-zA-Z])", idCardNumber); } }