Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/regex/20.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript GST标识号(GSTIN)的正则表达式_Javascript_Regex - Fatal编程技术网

Javascript GST标识号(GSTIN)的正则表达式

Javascript GST标识号(GSTIN)的正则表达式,javascript,regex,Javascript,Regex,印度GST编号的正则表达式是什么。有关GST编号的更多信息,请访问 在汇总级别上,数字表示为 列表项该数字的前两位数字代表2011年印度人口普查的州代码 接下来的十位数字将是纳税人的PAN编号 第十三位数字将根据一个州内的注册编号进行分配 默认情况下,第十四位数字为Z 最后一位数字将用于检查代码 正则表达式应为: /^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}Z[0-9]{1}$/ 正确的正则表达式可以是: /^[0-9]{2}[A-Z]{5}[0-9]

印度GST编号的正则表达式是什么。有关GST编号的更多信息,请访问 在汇总级别上,数字表示为

  • 列表项该数字的前两位数字代表2011年印度人口普查的州代码
  • 接下来的十位数字将是纳税人的PAN编号
  • 第十三位数字将根据一个州内的注册编号进行分配
  • 默认情况下,第十四位数字为Z
  • 最后一位数字将用于检查代码
正则表达式应为:

/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}Z[0-9]{1}$/

正确的正则表达式可以是:

/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[0-9]{1}Z[0-9]{1}?$/

它适合我。

这是我想出的正则表达式:

/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/
根据法律,第13位“数字”(实体代码)是“字母数字(先是1-9,然后是A-Z)”。也就是说,不允许为零,A-Z表示10-35。因此
[1-9A-Z]
[0-9]
更准确


最后一位数字“校验位”实际上是字母数字:
[0-9A-Z]
。我已经通过获取和测试实际的GSTIN来独立确认。

我使用了这一个,并将其与30+GSTIN进行了对比检查,它工作得完美无缺

/^[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}$/
在我遇到的一些GSTIN中,最后一个校验位似乎也是字母数字。

试试这个。 它正在按照GSTIN工作

^([a-zA-Z0-9_\.\-])+\@(([a-zA-Z0-9\-])+\.)+([a-zA-Z0-9]{2,4})+$

这是GSTIN的正则表达式和校验和验证

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

格式详细信息

  • 根据人口普查(2011年),GST编号的前两位数字将代表州代码
  • 接下来的10位数字将与纳税人的PAN编号相同。
    • 前五个是字母表
    • 接下来的四个是数字
    • 最后是检查代码
  • 第13位数字是您在一个州内的注册数量,即9之后,a到Z被视为10到35
  • 默认情况下,第14位数字为Z
  • 最后是检查代码

  • 以下是使用js中的校验和验证gstin编号的代码

    函数校验和(g){
    设regTest=/\d{2}[A-Z]{5}\d{4}[A-Z]{1}[A-Z\d]{1}[Z]{1}[A-Z\d]{1}/.test(g)
    if(regTest){
    设a=65,b=55,c=36;
    返回数组['from'](g).reduce((i,j,k,g)=>{
    p=(p=(j.charCodeAt(0)c?1+(p-c):p;
    
    返回kGSTIN的正确验证应为

    ^([0][1-9]|[1-2][0-9]|[3][0-7])([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$
    
    前两位数字表示陆地区域代码列表中定义的州代码(01-37)

    接下来的10个字符与AAAAA 9999X格式的PAN编号有关

    第13个字符表示一个实体在一个州内为同一PAN注册的数量

    第14个字符当前默认为“Z”

    第15个字符是校验和数字


    此正则表达式模式适用于小写和大写。
    GSTIN的正确的
    regex
    如下所示-

    ^([0][1-9]|[1-2][0-9]|[3][0-7])([A-Z]{5})([0-9]{4})([A-Z]{1}[1-9A-Z]{1})([Z]{1})([0-9A-Z]{1})+$
    

    以上一项是正确的,已应用于300多个有效纳税人,您可以通过此验证正确的GSTIN验证将覆盖印度27个州

    ^([0][1-9]|[1-2][0-9]|[3][0-7])([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$
    

    为了补充上述答案,此答案还提供了校验和数字的代码段

    public static final String GSTINFORMAT_REGEX = "[0-9]{2}[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9A-Za-z]{1}[Z]{1}[0-9a-zA-Z]{1}";
    public static final String GSTN_CODEPOINT_CHARS = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";
    public static String getGSTINWithCheckDigit(String gstinWOCheckDigit) throws Exception {
                int factor = 2;
                int sum = 0;
                int checkCodePoint = 0;
                char[] cpChars;
                char[] inputChars;
    
                try {
                    if (gstinWOCheckDigit == null) {
                        throw new Exception("GSTIN supplied for checkdigit calculation is null");
                    }
                    cpChars = GSTN_CODEPOINT_CHARS.toCharArray();
                    inputChars = gstinWOCheckDigit.trim().toUpperCase().toCharArray();
    
                    int mod = cpChars.length;
                    for (int i = inputChars.length - 1; i >= 0; i--) {
                        int codePoint = -1;
                        for (int j = 0; j < cpChars.length; j++) {
                            if (cpChars[j] == inputChars[i]) {
                                codePoint = j;
                            }
                        }
                        int digit = factor * codePoint;
                        factor = (factor == 2) ? 1 : 2;
                        digit = (digit / mod) + (digit % mod);
                        sum += digit;
                    }
                    checkCodePoint = (mod - (sum % mod)) % mod;
                    return gstinWOCheckDigit + cpChars[checkCodePoint];
                } finally {
                    inputChars = null;
                    cpChars = null;
                }
            }
    
    public static final String gstinformatu REGEX=“[0-9]{2}[a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9A-zA-Z]{1}[Z]{1}[0-9A-zA-Z]{1}”;
    公共静态最终字符串GSTN_CODEPOINT_CHARS=“0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ”;
    公共静态字符串getGSTINWithCheckDigit(字符串gstinWOCheckDigit)引发异常{
    整数因子=2;
    整数和=0;
    int checkCodePoint=0;
    char[]cpChars;
    字符[]输入字符;
    试一试{
    if(gstinWOCheckDigit==null){
    抛出新异常(“为校验位计算提供的GSTIN为空”);
    }
    cpChars=GSTN_CODEPOINT_CHARS.tocharray();
    inputChars=gstinWOCheckDigit.trim().toUpperCase().ToCharray();
    int mod=cpChars.length;
    对于(int i=inputChars.length-1;i>=0;i--){
    int码点=-1;
    对于(int j=0;j
    资料来源:,

    用jQuery试试这个

    $(文档).ready(函数(){
    $.validator.addMethod(“gst”,函数(value3,element3){
    var gst_value=value3.toUpperCase();
    var reg=/^([0-9]{2}[a-zA-Z]{4}([a-zA-Z]{1}[0-9]{1})[0-9]{4}[a-zA-Z]{1}([a-zA-Z]{0-9]){3}{0,15}$/;
    if(本选项(元素3)){
    返回true;
    }
    如果(gst_值匹配(reg)){
    返回true;
    }否则{
    返回false;
    }
    },“请指定有效的GSTTIN编号”);
    $('#myform')。验证({//初始化插件
    规则:{
    商品及服务税:{
    要求:正确,
    商品及服务税:对
    }
    },
    submitHandler:函数(表单){
    警报(“提交的有效表格”);
    返回false;
    }
    });
    });
    
    GSTTIN#
    登记
    
    如果需要节点库,可以使用


    这是可以在代码中使用的通用紧凑正则表达式:^\d{2}\d{5}\d{4}\d\dZ\w

    Swift 4 GSTIN验证代码如下:

        class func isValidGSTIN(_ gstin : String)-> Bool {
            let gstinRegex = "^\\d{2}\\D{5}\\d{4}\\D\\dZ\\w"
            let test = NSPredicate(format: "SELF MATCHES %@", gstinRegex)
            return test.evaluate(with: gstin.uppercased())
        }
    


    如果您使用yup,请尝试下面为我工作的代码

    gst_no:Yup.string()
        .trim()
        .matches(/[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[1-9A-Z]{1}$/ , 'Is not in correct format')
        .required(),  
    
    输入:21LKJLK1235M22

    这是GSTIN的100%精确正则表达式,因为它检查我的所有内容
        class func isValidGSTIN(_ gstin : String)-> Bool {
            let gstinRegex = "^\\d{2}\\D{5}\\d{4}\\D\\dZ\\w"
            let test = NSPredicate(format: "SELF MATCHES %@", gstinRegex)
            return test.evaluate(with: gstin.uppercased())
        }
    
    public static boolean validateGST(CharSequence gst){
             if(gst!=null)
              return Pattern.matches("\\d{2}[a-zA-Z]{5}\\d{4}[a-zA-Z] 
                                    {1}\\d{1}[zZ]{1}[\\da-zA-Z]{1}",gst);
          else
            return false;
      }
    
    gst_no:Yup.string()
        .trim()
        .matches(/[0-9]{2}[A-Z]{5}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}[1-9A-Z]{1}$/ , 'Is not in correct format')
        .required(),  
    
    [0-9]{2}[A-Z]{3}[ABCFGHLJPTF]{1}[A-Z]{1}[0-9]{4}[A-Z]{1}[1-9A-Z]{1}Z[0-9A-Z]{1}