正则 纳税号_GST标识号(GSTIN)的正则表达式

What is the regex for the GST number in India. You can read more about the GST numbers from https://cleartax.in/s/know-your-gstin

On a summary level the number is represented as

List itemThe first two digits of this number will represent the state code as per Indian Census 2011

The next ten digits will be the PAN number of the taxpayer

The thirteenth digit will be assigned based on the number of registration within a state

The fourteenth digit will be Z by default

The last digit will be for check code

解决方案

Here is the regex and checksum validation for GSTIN

\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}

Format details

First 2 digits of the GST Number will represent State Code as per the Census (2011).

Next 10 digits will be same as in the PAN number of the taxpayer.

First five will be alphabets

Next four will be numbers

Last will be check code

The 13th digit will be the number of registration you take within a state i.e. after 9, A to Z is considered as 10 to 35 .

14th digit will be Z by default.

Last would be the check code.

Here is the code for verifying/validating the gstin number using the checksum in js

function checksum(g){

let a=65,b=55,c=36;

return Array['from'](g).reduce((i,j,k,g)=>{

p=(p=(j.charCodeAt(0)c?1+(p-c):p;

return k<14?i+p:j==((c=(c-(i%c)))<10?c:String.fromCharCode(c+b));

},0);

}

console.log(checksum('27AAPFU0939F1ZV'))

console.log(checksum('27AASCS2460H1Z0'))

console.log(checksum('29AAGCB7383J1Z4'))

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值