# Matches an ANSI color
(?>
  (?<Console_24BitColor>
(?-i)\e                                                                                # An Escape
\[                                                                                     # Followed by a bracket
(?>
  (?<IsForegroundColor>38)  |
  (?<IsBackgroundColor>48)  |
  (?<IsUnderlineColor>58));2;(?<Color>(?<Red>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2}))    # Red is the first 0-255 value
;(?<Green>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2}))                                       # Green is the second 0-255 value
;(?<Blue>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2}))                                        # Blue is the third 0-255 value
m)
)
  |
  (?<Console_8BitColor>
(?-i)\e                                                                                # An Escape
\[                                                                                     # Followed by a bracket
(?>
  (?<IsForegroundColor>38)  |
  (?<IsBackgroundColor>48)  |
  (?<IsUnderlineColor>58));5;(?<Color>(?>
  (?<StandardColor>[0-7])                                                              # 0 -7 are standard colors
m  |
  (?<BrightColor>(?>[8-9]|1[0-5]))                                                     # 8-15 are bright colors
m  |
  (?<CubeColor>(?>[0-2][0-3][0-1]|[0-1]\d\d|\d{1,2}))                                  # 16-231  are cubed colors
m  |
  (?<GrayscaleColor>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2}))                             # 232-255 are grayscales
m))
)
  |
  (?<Console_4BitColor>
\e                                                                                     # An Escape
\[                                                                                     # Followed by a bracket
(?<Color>(?>
  (?<IsBright>1)?\;{0,1}                                                               # A 1 and a semicolon indicate a bright color
(?<IsForegroundColor>3)                                                                # A number that starts with 3 indicates foreground color
  |
  (?<IsBright>(?<IsForegroundColor>9))                                                 # OR it could be a less common bright foreground color, which starts with 9
  |
  (?<IsBright>1)?\;{0,1}                                                               # A 1 and a semicolon indicate a bright color
(?<IsBackgroundColor>4)                                                                # A number that starts with 3 indicates foreground color
  |
  (?<IsBright>(?<IsBackgroundColor>10))                                                # OR it could be a less common bright foreground color, which starts with 9
)(?<ColorNumber>[0-7])                                                                 # The color number will be between 0 and 7
(?:\;{0,1}(?<IsBright>1)?)?                                                            # Brightness can also come after a color
m)
)
  |
  (?<Console_DefaultColor>
(?-i)\e                                                                                # An Escape
\[                                                                                     # Followed by a bracket
(?<Color>(?>
  (?<DefaultForeground>39)                                                             # 39 Represents the default foreground color
m  |
  (?<DefaultForeground>49)                                                             # 49 Represents the default background color
m))
)
)
