# Matches an ANSI 24-bit color (?-i)\e # An Escape \[ # Followed by a bracket (?> (?38) | (?48) | (?58));2;(?(?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Red is the first 0-255 value ;(?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Green is the second 0-255 value ;(?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Blue is the third 0-255 value m)