Regex to match digits of specific length

前端 未结 3 1174
太阳男子
太阳男子 2020-11-29 04:51

I am looking to match a 15 digit number (as part of a larger regex string). Right now, I have

\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d\\d

3条回答
  •  无人及你
    2020-11-29 05:01

    There, are two ways i have, to limit numbers.

    using len,

    num = 1234
    len(str(num)) <= 4
    

    This output will be True / False.

    using regular expression,

    import re
    num = 12324
    re.match(r'(?:(?

    The output will be regular expression object or None.

提交回复
热议问题