Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8867683
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:06:13+00:00 2026-06-14T17:06:13+00:00

I have read through this question , but for Discover card, the starting digits

  • 0

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. (Source)

For Discover cards, I picked up this regex from that question ^6(?:011|5[0-9]{2})[0-9]{12}$

I modified it to cover 6011, 644-649& 65 but for 622126-622925, building regex is hard cuz of my poor regex skills.

I have this regex so far 6(?:011|5[0-9]{2}|[4][4-9][0-9]|[2]{2}[1-9])[0-9]{2}$, but it only checks for 622[1-9]**.

How do I modify it so that it accepts only between 622126-622925 for 622*** case?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-14T17:06:13+00:00Added an answer on June 14, 2026 at 5:06 pm

    Here’s your regex (demo):

    ^6(?:011\d{12}|5\d{14}|4[4-9]\d{13}|22(?:1(?:2[6-9]|[3-9]\d)|[2-8]\d{2}|9(?:[01]\d|2[0-5]))\d{10})$
    

    Needless to say, I won’t exactly call this pretty or easy to maintain. I would recommend parsing the number as an integer and using your programming language to do the checks.

    You should also use Luhn algorithm to check if the credit card number is valid, and while you could theoretically do this with regex, it would many times worse than this.


    Allow me to show you how I arrived at this monstrosity, step by step. First, here is how you match each of those ranges:

    6011        # matches 6011
    65          # matches 65
    64[4-9]     # matches 644-649
    622(1(2[6-9]|[3-9]\d)|[2-8]\d{2}|9([01]\d|2[0-5]))  
                # matches 622126-622925
    

    Now, you want to match the rest of the digits:

    6011\d{12}        # matches 6011 + 12 digits
    65\d{14}          # matches 65 + 14 digits
    64[4-9]\d{13}     # matches 644-649 + 13 digits
    622(1(2[6-9]|[3-9]\d)|[2-8]\d{2}|9([01]\d|2[0-5]))\d{10}
                      # matches 622126-622925 + 10 digits
    

    Now you can combine all four, and add start and end of line anchors:

    ^(                  # match start of string and open group
     6011\d{12}|        # matches 6011 + 12 digits
     65\d{14}|          # matches 65 + 14 digits
     64[4-9]\d{13}|     # matches 644-649 + 13 digits
     622(1(2[6-9]|[3-9]\d)|[2-8]\d{2}|9([01]\d|2[0-5]))\d{10}
                        # matches 622126-622925 + 10 digits
    )$                  # close group and match end of string
    

    The final product above is a slightly compacted version of the previous regex, and I also made groups non-capturing (that’s what those ?: are for).

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have read through this SO question about 32-bits, but what about 64-bit numbers?
I've read through the various posts on SO about this, but have still not
This question might seem a repeat of previous ones. I have read through a
this is a noobie question regarding tree maps. I have read through the Java
Ok, let me preface this question with the fact that I have read through
I have read through some articles on this topic but I am still cautious
This is probably not a dup; I have read through many similar problems on
First, thanks in advance for taking the time to read through this. I have
I have read through several articles which are alternatives to using setpixel/getpixel but I
I have read through some tutorials about javascript prototypal inheritance patterns but I am

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.