Skip to content

Commit 41c3c12

Browse files
Merge pull request #148 from StartAutomating/IrregularANSIFix
Irregular ansi fix
2 parents aa63deb + 1161c31 commit 41c3c12

20 files changed

+193
-84
lines changed

CHANGELOG.md

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,12 @@
1-
## 0.7.2:
1+
## 0.7.3:
2+
* ANSI Improvements:
3+
* Fixed ?<ANSI_Style> (Fixes #143)
4+
* ?<ANSI_4BitColor> now supports bright ranges (Fixes #145)
5+
* ?<ANSI_8BitColor>/?<ANSI_24BitColor> now supports background colors (Fixes #144)
6+
* ?<ANSI_8BitColor>/?<ANSI_24BitColor> now supports underline colors (Fixes #146)
7+
---
8+
9+
## 0.7.2:
210
* Lots More ANSI support:
311
* ?<ANSI_Bold> (Fixes #131)
412
* ?<ANSI_Blink> (Fixes #132)

Irregular.format.ps1xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-16"?>
2-
<!-- Generated with EZOut 1.9.3: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+
<!-- Generated with EZOut 1.9.4: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
33
<Configuration>
44
<ViewDefinitions>
55
<View>

Irregular.psd1

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
@{
2-
ModuleVersion = '0.7.2'
2+
ModuleVersion = '0.7.3'
33
RootModule = 'Irregular.psm1'
44
Description = 'Regular Expressions made Strangely Simple'
55
FormatsToProcess = 'Irregular.format.ps1xml'
@@ -14,6 +14,14 @@
1414
LicenseURI = 'https://github.com/StartAutomating/Irregular/blob/master/LICENSE'
1515
IconURI = 'https://github.com/StartAutomating/Irregular/blob/master/Assets/Irregular_600_Square.png'
1616
ReleaseNotes = @'
17+
## 0.7.3:
18+
* ANSI Improvements:
19+
* Fixed ?<ANSI_Style> (Fixes #143)
20+
* ?<ANSI_4BitColor> now supports bright ranges (Fixes #145)
21+
* ?<ANSI_8BitColor>/?<ANSI_24BitColor> now supports background colors (Fixes #144)
22+
* ?<ANSI_8BitColor>/?<ANSI_24BitColor> now supports underline colors (Fixes #146)
23+
---
24+
1725
## 0.7.2:
1826
* Lots More ANSI support:
1927
* ?<ANSI_Bold> (Fixes #131)

Irregular.types.ps1xml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
<?xml version="1.0" encoding="utf-16"?>
2-
<!-- Generated with EZOut 1.9.3: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+
<!-- Generated with EZOut 1.9.4: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
33
<Types>
44
<Type>
55
<Name>Irregular.Match.Extract</Name>

README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<h2>Regular Expressions made Strangely Simple</h2>
44
<h3>A PowerShell module that helps you understand, use, and build Regular Expressions.</h3>
55
<h4>
6-
<a href='https://github.com/StartAutomating/Irregular/releases/tag/v0.7.2'>v 0.7.2 </a>
6+
<a href='https://github.com/StartAutomating/Irregular/releases/tag/v0.7.3'>v 0.7.3 </a>
77
</h4>
88
<a href='https://www.powershellgallery.com/packages/Irregular/'>
99
<img src='https://img.shields.io/powershellgallery/dt/Irregular' />
@@ -32,7 +32,7 @@ Once you understand some basics of that syntax, regular expressions become a lot
3232
3. A Regex can have comments! ( # Like this in .NET ( or like (?#this comment) in ECMAScript ) ).
3333
4. You don't have to do it all in one expression!
3434

35-
Irregular comes with 128 useful [named expressions](SavedPatterns.md), and lets you create more.
35+
Irregular comes with 130 useful [named expressions](SavedPatterns.md), and lets you create more.
3636

3737
To see the expressions that ship with Irregular, run:
3838

RegEx/ANSI/24BitColor.regex.source.ps1

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,16 @@ $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path
44
New-RegEx -Description "Matches an ANSI 24-bit color" -Modifier IgnoreCase -Not |
55
New-RegEx -CharacterClass Escape -Comment 'An Escape' |
66
New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' |
7-
New-RegEx -Pattern '38;2;' |
7+
New-RegEx -Atomic -Or @(
8+
New-RegEx -Pattern '38' -Name IsForegroundColor
9+
New-RegEx -Pattern '48' -Name IsBackgroundColor
10+
New-RegEx -Pattern '58' -Name IsUnderlineColor
11+
) |
12+
New-RegEx -Pattern ';2;' |
813
New-RegEx -Name Color -Pattern (
914
New-Regex -Name Red -Pattern '(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})' -Comment 'Red is the first 0-255 value' |
1015
New-RegEx -Pattern ';' |
11-
New-Regex -Name Red -Pattern '(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})' -Comment 'Green is the second 0-255 value' |
16+
New-Regex -Name Green -Pattern '(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})' -Comment 'Green is the second 0-255 value' |
1217
New-RegEx -Pattern ';' |
1318
New-Regex -Name Blue -Pattern '(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})' -Comment 'Blue is the third 0-255 value' |
1419
New-RegEx -Pattern 'm'

RegEx/ANSI/24BitColor.regex.txt

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
# Matches an ANSI 24-bit color
2-
(?-i)\e # An Escape
3-
\[ # Followed by a bracket
4-
38;2;(?<Color>(?<Red>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Red is the first 0-255 value
5-
;(?<Red>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Green is the second 0-255 value
6-
;(?<Blue>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Blue is the third 0-255 value
2+
(?-i)\e # An Escape
3+
\[ # Followed by a bracket
4+
(?>
5+
(?<IsForegroundColor>38) |
6+
(?<IsBackgroundColor>48) |
7+
(?<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
8+
;(?<Green>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Green is the second 0-255 value
9+
;(?<Blue>(?>[0-2][0-5][0-5]|[0-1]\d\d|\d{1,2})) # Blue is the third 0-255 value
710
m)

RegEx/ANSI/4BitColor.regex.source.ps1

Lines changed: 21 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,25 @@ New-RegEx -Description "Matches an ANSI 3 or 4-bit color" |
55
New-RegEx -CharacterClass Escape -Comment 'An Escape' |
66
New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' |
77
New-RegEx -Pattern (
8-
New-RegEx -Pattern 1 -Optional -Name IsBright |
9-
New-RegEx -LiteralCharacter ';' -Optional |
10-
New-RegEx -Pattern '3[0-7]' -Name ForegroundColor -Optional |
11-
New-RegEx -If ForegroundColor -Then 'm' -Else (
12-
New-RegEx -Pattern '4[0-7]' -Name BackgroundColor |
13-
New-RegEx -Pattern 'm' -Modifier IgnoreCase -Not
14-
)
15-
) -Name Color |
8+
9+
New-RegEx -Atomic -Or @(
10+
New-RegEx -Pattern 1 -Optional -Name IsBright |
11+
New-RegEx -LiteralCharacter ';' -Min 0 -Max 1 |
12+
New-RegEx -Pattern '3' -Name IsForegroundColor
13+
14+
New-RegEx -Name IsBright (
15+
New-RegEx -Pattern '9' -Name IsForegroundColor
16+
)
17+
18+
New-RegEx -Pattern 1 -Optional -Name IsBright |
19+
New-RegEx -LiteralCharacter ';' -Min 0 -Max 1 |
20+
New-RegEx -Pattern '4' -Name IsBackgroundColor
21+
22+
New-RegEx -Name IsBright (
23+
New-RegEx -Pattern '10' -Name IsBackgroundColor
24+
)
25+
) |
26+
New-RegEx -Pattern '[0-7]' -Name ColorNumber |
27+
New-RegEx -LiteralCharacter 'm'
28+
) -Name Color | #>
1629
Set-Content -Path (Join-Path $myRoot $myName)

RegEx/ANSI/4BitColor.regex.txt

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
# Matches an ANSI 3 or 4-bit color
22
\e # An Escape
33
\[ # Followed by a bracket
4-
(?<Color>(?<IsBright>1)?\;?(?<ForegroundColor>3[0-7])?(?(ForegroundColor)(m)|((?<BackgroundColor>4[0-7])m)))
4+
(?<Color>(?>
5+
(?<IsBright>1)?\;{0,1}(?<IsForegroundColor>3) |
6+
(?<IsBright>(?<IsForegroundColor>9)) |
7+
(?<IsBright>1)?\;{0,1}(?<IsBackgroundColor>4) |
8+
(?<IsBright>(?<IsBackgroundColor>10)))(?<ColorNumber>[0-7])m)

RegEx/ANSI/8BitColor.regex.source.ps1

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,12 @@ $myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path
44
New-RegEx -Description "Matches an ANSI 8-bit color" -Modifier IgnoreCase -Not |
55
New-RegEx -CharacterClass Escape -Comment 'An Escape' |
66
New-RegEx -LiteralCharacter '[' -Comment 'Followed by a bracket' |
7-
New-RegEx -Pattern '38;5;' |
7+
New-RegEx -Atomic -Or @(
8+
New-RegEx -Pattern '38' -Name IsForegroundColor
9+
New-RegEx -Pattern '48' -Name IsBackgroundColor
10+
New-RegEx -Pattern '58' -Name IsUnderlineColor
11+
) |
12+
New-RegEx -Pattern ';5;' |
813
New-RegEx -Name Color -Pattern (
914
New-RegEx -Atomic -Or @(
1015
New-Regex -Name StandardColor -Pattern '[0-7]' -Comment '0 -7 are standard colors' |

0 commit comments

Comments
 (0)