如何验证PAN卡? [英] How to verify PAN card?

查看:122
本文介绍了如何验证PAN卡?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何检查诸如"ABCDE1234F"之类的Pan卡的edittext的有效性.我很困惑如何检查此验证.请帮助我.我将不胜感激.

How to check the validation of edittext for pan card like "ABCDE1234F". I am confused how to check the the validation for this. Please help me guys. I will appreciate any kind of help.

推荐答案

您可以将正则表达式与模式匹配配合使用

You can use Regular Expression with pattern matching

String s = "ABCDE1234F"; // get your editext value here
Pattern pattern = Pattern.compile("[A-Z]{5}[0-9]{4}[A-Z]{1}");

Matcher matcher = pattern.matcher(s);
// Check if pattern matches 
if (matcher.matches()) {
  Log.i("Matching","Yes");
}   

[A-Z]{5} - match five literals which can be A to Z
[0-9]{4} - followed by 4 numbers 0 to 9
[A-Z]{1} - followed by one literal which can A to Z

您可以测试正则表达式@

You can test regex @

http://java-regex-tester.appspot.com/

http://docs.oracle.com/javase/tutorial/essential/regex/

这篇关于如何验证PAN卡?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆