Java tutorial
//package com.java2s; import android.widget.EditText; public class Main { private static final String ID_CARD_REG = "^(\\d{15}|\\d{18}|\\d{17}[x,X])$"; public static boolean isValidIdCard(EditText paramEditText) { return (paramEditText != null) && (isValidIdCard(paramEditText.getText().toString())); } public static boolean isValidIdCard(String paramString) { return (paramString != null) && (paramString.matches(ID_CARD_REG)); } }