diff --git a/RegEx/ANSI/Style.regex.source.ps1 b/RegEx/ANSI/Style.regex.source.ps1 index 0f7e432..b750428 100644 --- a/RegEx/ANSI/Style.regex.source.ps1 +++ b/RegEx/ANSI/Style.regex.source.ps1 @@ -10,7 +10,7 @@ New-RegEx -Description "Matches an ANSI style (color or text option)" | New-Regex -Pattern '?' New-Regex -Pattern '?' New-Regex -Pattern '?' - New-Regex -Pattern '?' + New-Regex -Pattern '?' New-Regex -Pattern '?' New-RegEx -Pattern '?' New-RegEx -Pattern '?' diff --git a/RegEx/ANSI/Style.regex.txt b/RegEx/ANSI/Style.regex.txt index 25d8f77..dd759cd 100644 --- a/RegEx/ANSI/Style.regex.txt +++ b/RegEx/ANSI/Style.regex.txt @@ -1,122 +1,141 @@ # Matches an ANSI style (color or text option) (?> (? -\e # An Escape -\[ # Followed by a bracket -(?0m) # 0m indicates reset +\e # An Escape +\[ # Followed by a bracket +(?0m) # 0m indicates reset ) | (? -\e # An Escape -\[ # Followed by a bracket +\e # An Escape +\[ # Followed by a bracket (?> (?1m) | (?22m)) ) | (? -\e # An Escape -\[ # Followed by a bracket +\e # An Escape +\[ # Followed by a bracket (?> (?> - (?(?5m) # 5m starts a slow blink + (?(?5m) # 5m starts a slow blink | - (?6m) # 6m starts a slow blink + (?6m) # 6m starts a slow blink )) | - (?25m) # 25m stops blinks + (?25m) # 25m stops blinks ) ) | (? -\e # An Escape -\[ # Followed by a bracket +\e # An Escape +\[ # Followed by a bracket (?> - (?2m) # 2m starts faint + (?2m) # 2m starts faint | - (?22m) # 22m stops faint + (?22m) # 22m stops faint ) ) | (? -\e # An Escape -\[ # Followed by a bracket +\e # An Escape +\[ # Followed by a bracket (?> - (?3m) # 3m starts italic + (?3m) # 3m starts italic | - (?23m) # 23m stops italic + (?23m) # 23m stops italic ) ) | (? -\e # An Escape -\[ # Followed by a bracket +\e # An Escape +\[ # Followed by a bracket (?> - (?7m) # 7m starts invert + (?7m) # 7m starts invert | - (?27m) # 27m stops invert + (?27m) # 27m stops invert ) ) | (? -\e # An Escape -\[ # Followed by a bracket +\e # An Escape +\[ # Followed by a bracket (?> - (?8m) # 8m starts hide + (?8m) # 8m starts hide | - (?28m) # 28m stops hide + (?28m) # 28m stops hide +) +) + | + (? +\e # An Escape +\[ # Followed by a bracket +(?> + (?9m) # 9m starts Strikethrough + | + (?29m) # 29m stops Strikethrough ) ) | - ? | (? -\e # An Escape -\[ # Followed by a bracket +\e # An Escape +\[ # Followed by a bracket (?> - (?4m) # 4m starts underline + (?4m) # 4m starts underline | - (?21m) # 21m start a double underline + (?21m) # 21m start a double underline | - (?24m) # 24m stops underline + (?24m) # 24m stops underline ) ) | (? -(?-i)\e # An Escape -\[ # Followed by a bracket -38;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 +(?-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) ) | (? -(?-i)\e # An Escape -\[ # Followed by a bracket -38;5;(?(?> - (?[0-7]) # 0 -7 are standard colors +(?-i)\e # An Escape +\[ # Followed by a bracket +(?> + (?38) | + (?48) | + (?58));5;(?(?> + (?[0-7]) # 0 -7 are standard colors m | - (?(?>[8-9]|1[0-5])) # 8-15 are bright colors + (?(?>[8-9]|1[0-5])) # 8-15 are bright colors m | - (?(?>[0-2][0-3][0-1]|[0-1]\d\d|\d{1,2})) # 16-231 are cubed colors + (?(?>[0-2][0-3][0-1]|[0-1]\d\d|\d{1,2})) # 16-231 are cubed colors m | - (?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # 232-255 are grayscales + (?(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # 232-255 are grayscales m)) ) | (? -\e # An Escape -\[ # Followed by a bracket -(?(?1)?\;?(?3[0-7])?(?(ForegroundColor)(m)|((?4[0-7])m))) +\e # An Escape +\[ # Followed by a bracket +(?(?> + (?1)?\;{0,1}(?3) | + (?(?9)) | + (?1)?\;{0,1}(?4) | + (?(?10)))(?[0-7])m) ) | (? -(?-i)\e # An Escape -\[ # Followed by a bracket +(?-i)\e # An Escape +\[ # Followed by a bracket (?(?> - (?39) # 39 Represents the default foreground color + (?39) # 39 Represents the default foreground color m | - (?49) # 49 Represents the default background color + (?49) # 49 Represents the default background color m)) ) )