-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathColor.regex.txt
41 lines (41 loc) · 1.76 KB
/
Color.regex.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
# Matches an ANSI color
(?>
(?<ANSI_24BitColor>
(?-i)\e # An Escape
\[ # Followed by a bracket
38;2;(?<Color>(?<Red>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Red is the first 0-255 value
;(?<Red>(?>[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)
)
|
(?<ANSI_8BitColor>
(?-i)\e # An Escape
\[ # Followed by a bracket
38;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))
)
|
(?<ANSI_4BitColor>
\e # An Escape
\[ # Followed by a bracket
(?<Color>(?<IsBright>1)?\;?(?<ForegroundColor>3[0-7])?(?(ForegroundColor)(m)|((?<BackgroundColor>4[0-7])m)))
)
|
(?<ANSI_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))
)
)