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 6670103
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T03:13:45+00:00 2026-05-26T03:13:45+00:00

In another question I learned how to calculate straight poker hand using regex (

  • 0

In another question I learned how to calculate straight poker hand using regex (here).

Now, by curiosity, the question is: can I use regex to calculate the same thing, using ASCII CODE?

Something like:

regex: [C][C+1][C+2][C+3][C+4], being C the ASCII CODE (or like this)

Matches: 45678, 23456

Doesn’t matches: 45679 or 23459 (not in sequence)

  • 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-05-26T03:13:45+00:00Added an answer on May 26, 2026 at 3:13 am

    SOLVED!

    See in http://jsfiddle.net/g48K9/3

    I solved using closure, in js.

    String.prototype.isSequence = function () {
        If (this == "A2345") return true; // an exception
        return this.replace(/(\w)(\w)(\w)(\w)(\w)/, function (a, g1, g2, g3, g4, g5) {
            return    code(g1) == code(g2) -1 &&
                    code(g2) == code(g3) -1 &&
                    code(g3) == code(g4) -1 &&
                    code(g4) == code(g5) -1;
        })
    };
    
    function code(card){
        switch(card){
            case "T": return 58;
            case "J": return 59;
            case "Q": return 60;
            case "K": return 61;
            case "A": return 62;
            default: return card.charCodeAt();
        }
    }
    
    
    test("23456");
    test("23444");
    test("789TJ");
    test("TJQKA");
    test("8JQKA");
    
    function test(cards) {
        alert("cards " + cards + ": " + cards.isSequence())
    }
    

    Just to clarify, ascii codes:

    ASCII CODES:

    2 = 50
    3 = 51
    4 = 52
    5 = 53
    6 = 54
    7 = 55
    8 = 56
    9 = 57
    T = 84 -> 58
    J = 74 -> 59
    Q = 81 -> 60
    K = 75 -> 61
    A = 65 -> 62
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I always coded console applications and learned some basic UML/patterns skills, using C++. Now
After what I learned from my previous question , I would like to use
I hate to ask another how do you do this with regex question on
This question has been asked, in one form or another, a dozen times here,
I've been using minidom to parse XML for years. Now I've suddenly learned about
Yes another question that is a little Unique because I cant find the same
NOTE: I accidentally put another question's sentence in here (massive apologies on my part),
Back in the past I learned a lot about CSS but now I can't
Another question asked about determining odd/evenness in C, and the idiomatic (x & 1)
Another question related to this one . I have a List<SortableObjects> that is the

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.