RegEx pattern any two letters followed by six numbers

前端 未结 5 1190
灰色年华
灰色年华 2020-11-30 00:36

Please assist with the proper RegEx matching. Any 2 letters followed by any combination of 6 whole numbers.

These would be valid: 
RJ123456
PY654321
DD3212         


        
5条回答
  •  离开以前
    2020-11-30 01:05

    I depends on what is the regexp language you use, but informally, it would be:

    [:alpha:][:alpha:][:digit:][:digit:][:digit:][:digit:][:digit:][:digit:]
    

    where [:alpha:] = [a-zA-Z] and [:digit:] = [0-9]

    If you use a regexp language that allows finite repetitions, that would look like:

    [:alpha:]{2}[:digit:]{6}
    

    The correct syntax depends on the particular language you're using, but that is the idea.

提交回复
热议问题