Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    primarykey
    data
    text
    <p>I have to admit that regular expressions are not the first tool I would have thought of for doing this. I can pretty much guarantee that any RE capable of doing that to an unsorted hand is going to be far more hideous and far less readable than the equivalent procedural code.</p> <p>Assuming the cards are sorted by face value (and they seem to be otherwise your listed regexes wouldn't work either), and you <em>must</em> use a regex, you <em>could</em> use a construct like </p> <pre><code>2345A|23456|34567|...|9TJQK|TJQKA </code></pre> <p>to detect the face value part of the hand.</p> <p>In fact, from what I gather <a href="http://www.pokerstars.com/poker/games/rules/hand-rankings/" rel="nofollow noreferrer">here</a> of the "standard" hands, the following should be checked in order of decreasing priority:</p> <pre><code>Royal/straight flush: "(2345A|23456|34567|...|9TJQK|TJQKA)#(\\w)\\1{4}" Four of a kind: ".*(\\w)\\1{3}.*#.*" Full house: "((\\w)\\2\\2(\\w)\\3|(\\w)\\4(\\w)\\5\\5)#.*" Flush: ".*#(\\w)\\1{4}" Straight: "(2345A|23456|34567|...|9TJQK|TJQKA)#.*" Three of a kind: ".*(\\w)\\1\\1.*#.*" Two pair: ".*(\\w)\\1.*(\\w)\\2.*#.*" One pair: ".*(\\w)\\1.*#.*" High card: (none) </code></pre> <p>Basically, those are the same as yours except I've added the royal/straight flush and the straight. Provided you check them in order, you should get the best score from the hand. There's no regex for the high card since, at that point, it's the only score you can have.</p> <p>I also changed the steel wheel (wrap-around) straights from <code>A2345</code> to <code>2345A</code> since they'll be sorted that way.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. VO
      singulars
      1. This table or related slice is empty.
    2. VO
      singulars
      1. This table or related slice is empty.
    3. VO
      singulars
      1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload