RegexWars
Tier 4 · Enchantercapture

Name The Flush

A hand is five cards as "AS 2H 5D 9C KS" — rank then suit, space separated. Ranks are A23456789TJQK (T is ten), suits are SHDC. Capture the suit if all five cards share one; no match if they do not.

You cannot say "the same suit again" with a character class — [SHDC] would happily match a different one each time. A backreference matches the text a group actually captured, so capture the first card's suit once and insist on it four more times.

Your pattern0 chars · par 16
//
Flags
Start typing — tests run as you go.0 of 4 visible tests passing
Test cases
  • AS 2S 5S 9S KS→ ["S"]
  • 3H 4H 8H TH JH→ ["H"]
  • AS 2S 5S 9S KHmust not match

    the last card breaks it

  • AH 2S 5S 9S KSmust not match

    four spades and a heart

+ 7 hidden tests, checked when you submit. They are what stops a pattern that only fits the examples above.