-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy path4BitColor.regex.txt
16 lines (16 loc) · 941 Bytes
/
4BitColor.regex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
# Matches an ANSI 3 or 4-bit color
\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)