Regex for Discover credit card

前端 未结 3 682
一整个雨季
一整个雨季 2021-01-11 15:43

I have read through this question, but for Discover card, the starting digits are 6011, 622126-622925, 644-649, 65 instead of just 6011, 65. (Sourc

3条回答
  •  孤独总比滥情好
    2021-01-11 16:16

    Here are your options:

    1. Hack your way through it and build a really complicated regex. Regexes are not suited for this sort of integer comparison so what you come up with will necessarily be long, uncomplicated and unmaintainable. See Regex for number check below a value and similar SO questions on this topic.
    2. Use integer comparison in your code.

    For reference one such said complicated regex would be

    62212[6-9]|6221[3-9]|622[1-8]|62291|62292[1-5]

提交回复
热议问题