Skip to content

Commit 3e1443d

Browse files
Merge pull request #196 from StartAutomating/Irregular-Updates
Irregular 0.7.8
2 parents 99e11b1 + f979564 commit 3e1443d

File tree

73 files changed

+696
-177
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

73 files changed

+696
-177
lines changed

CHANGELOG.md

Lines changed: 16 additions & 1 deletion

Compress-RegEx.ps1

Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
function Compress-Regex
2+
{
3+
<#
4+
.SYNOPSIS
5+
Compresses Regular Expressions
6+
.DESCRIPTION
7+
Compresses a Regular Expression, removing all whitespace and comments.
8+
9+
This will make a regular expression much more difficult to read, and a bit shorter.
10+
.EXAMPLE
11+
New-Regex -Description "This is a description of a regex nobody will care about" |
12+
New-Regex -Name Width @(
13+
?<Decimals>
14+
) |
15+
New-Regex -Name Height @(
16+
?<Decimals>
17+
) | Compress-Regex
18+
#>
19+
param(
20+
# The regular expression to compress.
21+
[Parameter(Mandatory,
22+
ValueFromPipeline,
23+
ValueFromPipelineByPropertyName,
24+
Position=0)]
25+
[Alias('RegularExpression','Pattern','Expression')]
26+
[Regex]
27+
$Regex,
28+
29+
# The Match Timeout.
30+
# By default, this value will be carried over from the -RegEx.
31+
[timespan]
32+
$MatchTimeout = '00:00:01'
33+
)
34+
35+
process {
36+
# Create a new regex from the old:
37+
[Regex]::new(
38+
(
39+
# To compress the regex, split it by newlines
40+
"$Regex" -split '(?>\r\n|\n)' -replace
41+
# and strip comments
42+
'(?<!\\)#.+$' -join ([Environment]::NewLine) -replace
43+
# and strip whitespace.
44+
'[\s\n\r]'
45+
),
46+
# We'll keep the regex options should remain the same, for now.
47+
$Regex.Options,
48+
$(
49+
# If we provided a -MatchTimeout
50+
if ($PSBoundParameters["MatchTimeout"]) {
51+
$MatchTimeout # use that
52+
} elseif ($Regex.MatchTimeout.TotalSeconds -gt 0) {
53+
$Regex.MatchTimeout # otherwise, carry the timeout from the [Regex]
54+
} else {
55+
$MatchTimeout # and if it didn't have one, use the default for -MatchTimeout.
56+
}
57+
)
58+
)
59+
}
60+
}

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.9: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+
<!-- Generated with EZOut 2.0: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
33
<Configuration>
44
<ViewDefinitions>
55
<View>

Irregular.psd1

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,34 @@
11
@{
2-
ModuleVersion = '0.7.7'
2+
ModuleVersion = '0.7.8'
33
RootModule = 'Irregular.psm1'
44
Description = 'Regular Expressions made Strangely Simple'
55
FormatsToProcess = 'Irregular.format.ps1xml'
66
TypesToProcess = 'Irregular.types.ps1xml'
77
Guid = '39eb966d-7437-4e2c-abae-a496e933fb23'
88
Author = 'James Brundage'
9-
Copyright = '2019-2022 Start-Automating'
9+
Copyright = '2019-2023 Start-Automating'
1010
PrivateData = @{
1111
PSData = @{
1212
Tags = 'RegularExpressions', 'RegEx', 'Irregular', 'PatternMatching', 'PipeScript'
1313
ProjectURI = 'https://github.com/StartAutomating/Irregular'
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.8:
18+
19+
* Adding Compress-Regex (Fixes #178)
20+
* New Regexes:
21+
* ?<YAML_Value> (Fixes #192)
22+
* ?<YAML_Key> (Fixes #191)
23+
* ?<Degrees> (Fixes #185)
24+
* ?<Git_Commit> (Fixes #193)
25+
* ?<RegularExpression_GroupName> ( #195 )
26+
* ?<PowerShell_Hashtable> ( Fixes #194 )
27+
* ?<PowerShell_Requires>: Allowing open ended requirement (Fixes #182)
28+
Renaming ANSI Regexes to Console (Fixes #188)
29+
30+
---
31+
1732
## 0.7.7:
1833
1934
New Patterns:
@@ -211,6 +226,19 @@ Hat Tips: @JayKul, @LaurentDardenne
211226
Additional Changes in [ChangeLog](CHANGELOG.md)
212227
'@
213228
}
229+
ScriptTypes = @{
230+
RegExGenerator = @{
231+
Pattern = '\.regex\.ps1$'
232+
}
233+
RegExSource = @{
234+
Pattern = '\.regex\.source\.ps1$'
235+
}
236+
}
237+
ApplicationTypes = @{
238+
RegExFile = @{
239+
Pattern ='\.regex\.txt'
240+
}
241+
}
214242
}
215243
}
216244

Irregular.psm1

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
. $psScriptRoot\Get-RegEx.ps1
2+
. $psScriptRoot\Compress-RegEx.ps1
23
. $psScriptRoot\Export-RegEx.ps1
34
. $psScriptRoot\Import-RegEx.ps1
45
. $psScriptRoot\New-RegEx.ps1

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.9: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
2+
<!-- Generated with EZOut 2.0: 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

RegEx/ANSI/ANSI.tests.ps1

Lines changed: 0 additions & 27 deletions
This file was deleted.

RegEx/ANSI/README.md

Lines changed: 0 additions & 28 deletions
This file was deleted.

RegEx/ANSI/Style.regex.source.ps1

Lines changed: 0 additions & 20 deletions
This file was deleted.

0 commit comments

Comments
 (0)