Skip to content

Commit

Permalink
Merge pull request #174 from StartAutomating/Irregular-Updates
Browse files Browse the repository at this point in the history
Irregular 0.7.7
  • Loading branch information
StartAutomating authored Dec 15, 2022
2 parents 51e8035 + 432fc91 commit 38633d5
Show file tree
Hide file tree
Showing 19 changed files with 149 additions and 19 deletions.
12 changes: 11 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,14 @@
## 0.7.6:
## 0.7.7:

New Patterns:

* ?<Code_Method> : Matches methods in most languages (Fixes #171)
* ?<Code_PackageVersion> : Matches a package name and version (Fixes #172)
* ?<ANSI_Link> : Matches an ANSI Hyperlink (Fixes #173)

---

## 0.7.6:

* New-RegEx improvements:
* Now supporting new character classes: MarkSpacing, MarkEnclosing, MarkNonEnclosing (Fixes #168)
Expand Down
2 changes: 1 addition & 1 deletion Irregular.format.ps1xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-16"?>
<!-- Generated with EZOut 1.9.7: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<!-- Generated with EZOut 1.9.9: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<Configuration>
<ViewDefinitions>
<View>
Expand Down
14 changes: 12 additions & 2 deletions Irregular.psd1
Original file line number Diff line number Diff line change
@@ -1,19 +1,29 @@
@{
ModuleVersion = '0.7.6'
ModuleVersion = '0.7.7'
RootModule = 'Irregular.psm1'
Description = 'Regular Expressions made Strangely Simple'
FormatsToProcess = 'Irregular.format.ps1xml'
TypesToProcess = 'Irregular.types.ps1xml'
Guid = '39eb966d-7437-4e2c-abae-a496e933fb23'
Author = 'James Brundage'
Copyright = '2019-2021 Start-Automating'
Copyright = '2019-2022 Start-Automating'
PrivateData = @{
PSData = @{
Tags = 'RegularExpressions', 'RegEx', 'Irregular', 'PatternMatching', 'PipeScript'
ProjectURI = 'https://github.com/StartAutomating/Irregular'
LicenseURI = 'https://github.com/StartAutomating/Irregular/blob/master/LICENSE'
IconURI = 'https://github.com/StartAutomating/Irregular/blob/master/Assets/Irregular_600_Square.png'
ReleaseNotes = @'
## 0.7.7:
New Patterns:
* ?<Code_Method> : Matches methods in most languages (Fixes #171)
* ?<Code_PackageVersion> : Matches a package name and version (Fixes #172)
* ?<ANSI_Link> : Matches an ANSI Hyperlink (Fixes #173)
---
## 0.7.6:
* New-RegEx improvements:
Expand Down
2 changes: 1 addition & 1 deletion Irregular.types.ps1xml
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-16"?>
<!-- Generated with EZOut 1.9.7: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<!-- Generated with EZOut 1.9.9: Install-Module EZOut or https://github.com/StartAutomating/EZOut -->
<Types>
<Type>
<Name>Irregular.Match.Extract</Name>
Expand Down
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h2>Regular Expressions made Strangely Simple</h2>
<h3>A PowerShell module that helps you understand, use, and build Regular Expressions.</h3>
<h4>
<a href='https://github.com/StartAutomating/Irregular/releases/tag/v0.7.6'>v 0.7.6 </a>
<a href='https://github.com/StartAutomating/Irregular/releases/tag/v0.7.7'>v 0.7.7 </a>
</h4>
<a href='https://www.powershellgallery.com/packages/Irregular/'>
<img src='https://img.shields.io/powershellgallery/dt/Irregular' />
Expand Down Expand Up @@ -32,7 +32,7 @@ Once you understand some basics of that syntax, regular expressions become a lot
3. A Regex can have comments! ( # Like this in .NET ( or like (?#this comment) in ECMAScript ) ).
4. You don't have to do it all in one expression!

Irregular comes with 134 useful [named expressions](SavedPatterns.md), and lets you create more.
Irregular comes with 138 useful [named expressions](SavedPatterns.md), and lets you create more.

To see the expressions that ship with Irregular, run:

Expand Down
17 changes: 17 additions & 0 deletions RegEx/ANSI/Link.regex.source.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
$myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt'
$myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path

New-RegEx -Description "Matches ANSI Hyperlink" |
New-RegEx -CharacterClass Escape -Comment 'An Escape' |
New-RegEx -LiteralCharacter ']' -Comment 'Followed by a right bracket' |
New-RegEx -Pattern '8[^;]{0,};;' -Comment 'Followed by 8 (and optional non-semicolon content) and two semicolons' |
New-RegEx -Until '\e' -Name Uri -Comment 'Followed by the uri' |
New-RegEx -CharacterClass Escape -Comment 'Followed by an escape' |
New-RegEx -LiteralCharacter '\' -Comment 'Followed by a slash' |
New-RegEx -Until '\e' -Name Text -Comment 'Followed by the link text' |
New-RegEx -CharacterClass Escape -Comment 'Followed by an escape' |
New-RegEx -LiteralCharacter ']' -Comment 'Followed by a right bracket' |
New-RegEx -Pattern '8[^;]{0,};;' -Comment 'Followed by 8 (and optional non-semicolon content) and two semicolons' |
New-RegEx -CharacterClass Escape -Comment 'Followed by an Escape' |
New-RegEx -LiteralCharacter '\' -Comment 'Finally a closing slash' |
Set-Content -Path (Join-Path $myRoot $myName)
14 changes: 14 additions & 0 deletions RegEx/ANSI/Link.regex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Matches ANSI Hyperlink
\e # An Escape
\] # Followed by a right bracket
8[^;]{0,};; # Followed by 8 and two semicolons
(?<Uri>(?:.|\s){0,}?(?=\z|\e)) # Followed by the uri
\e # Followed by an escape
\\ # Followed by a slash
(?<Text>(?:.|\s){0,}?(?=\z|\e)) # Followed by the link text
\e # Followed by an escape
\] # Followed by a right bracket
8[^;]{0,};; # Followed by 8 and two semicolons
\e # Followed by an Escape
\\ # Finally a closing slash

1 change: 1 addition & 0 deletions RegEx/ANSI/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ Note: Using these regular expressions in the terminal may result in awkward out
|[?<ANSI_Hide>](Hide.regex.txt) |Matches ANSI Hide (aka conceal) Start or End |[source](Hide.regex.source.ps1) |
|[?<ANSI_Invert>](Invert.regex.txt) |Matches ANSI Invert Start or End |[source](Invert.regex.source.ps1) |
|[?<ANSI_Italic>](Italic.regex.txt) |Matches ANSI Italic Start or End |[source](Italic.regex.source.ps1) |
|[?<ANSI_Link>](Link.regex.txt) |Matches ANSI Hyperlink |[source](Link.regex.source.ps1) |
|[?<ANSI_Note>](Note.regex.txt) |Matches an ANSI VT520 Note |[source](Note.regex.source.ps1) |
|[?<ANSI_Reset>](Reset.regex.txt) |Matches an ANSI Reset (this clears formatting) |[source](Reset.regex.source.ps1) |
|[?<ANSI_Strikethrough>](Strikethrough.regex.txt)|Matches ANSI Strikethrough (aka crossed out) Start or End |[source](Strikethrough.regex.source.ps1)|
Expand Down
10 changes: 10 additions & 0 deletions RegEx/Code/Method.regex.source.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
$myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt'
$myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path

New-RegEx -Description "Matches methods in most languages" |
New-RegEx -After (
New-RegEx -CharacterClass Punctuation, Whitespace, Tab
) -Comment "Methods start after punctuation or whitespace" |
New-RegEx -CharacterClass Word -LiteralCharacter _ -Repeat -Name MethodName -Comment "Method names can be any word character or undererscore" |
New-RegEx -Description "A Generic Balancing Expression" -Name MethodParameters -Pattern '?<GenericBalancingExpression>' |
Set-Content -Path (Join-Path $myRoot $myName)
14 changes: 14 additions & 0 deletions RegEx/Code/Method.regex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
# Matches methods in most languages
(?<=[\p{P}\s\t]) # Methods start after punctuation or whitespace
(?<MethodName>[\w_]+) # Method names can be any word character or undererscore
# A Generic Balancing Expression
(?<MethodParameters>(?<GenericBalancingExpression>
\p{Ps} # The open punctuation
(?>
[^\p{Ps}\p{Pe}]+| # Anything that is neither open or closed punctuation
\p{Ps}(?<Depth>)| # If it's open punctuation, increment depth
\p{Pe}(?<-Depth>) # If it's closed punctuation, decrement depth
)*(?(Depth)(?!)) # Match until depth is empty
\p{Pe} # The closing punctuation
)
)
33 changes: 33 additions & 0 deletions RegEx/Code/PackageVersion.regex.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# Matches a Package Name with a Version.
# Includes captures for Name, Version, Major, Minor, Patch, Build, and Prerelease, and Extension
^ # Match the start
(?<Name> # The (?<Name>) is...
.+?(?=\z|[\.\-\@]\d+) # ...anything until a . followed by a digit (or end of string)
)
[\.\@] # Now we match a dot, at, or dash
(?<Version> # The (?<Version>) is...
(?<Major>\d+)[\.\-] # A (?<Major>) version digit, followed by a dot
(?<Minor>\d+(?:[\.\-])?)? # [Optional] a (?<Minor>) version digit, followed by a dot
(?<Patch>\d+(?:[\.\-])?)? # [Optional], a (?<Patch>) version digit, followed by a dot
(?<Build>\d+(?:[\.\-])?)? # [Optional], a (?<Build>) version digit, followed by a dot
(?(Build) # [Optional], If a (?<Build>) was found
(?:(?=)) # capture nothing and move on
| # Else
\+(?<Build>[\w-]+) # Match a + followed by a build identifier
)?
(?: # [Optional]
- # match a -
(?<Prerelease>[\w-]+) # followed by a (?<Prerelease>) identifier
)?
(?(Build) # [Optional], If a (?<Build>) was found
(?:(?=)) # capture nothing and move on
| # otherwise
\+(?<Build>[\w-]+) # Match a + followed by a build identifier
)?
)
(?: # [Optional]
\. # Match a final .
(?<Extension> # The (?<Extension>) is
.+?$ # anything until the end of the string
)
)?
14 changes: 8 additions & 6 deletions RegEx/Code/README.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,14 @@
This directory contains regular expressions that may be helpful in parsing language agonstic coding conventions.


|Name |Description |Source |
|----------------------------------------------------|---------------------------------------------------------------------------------------|-----------------------------|
|[?<Code_BuildVersion>](BuildVersion.regex.txt) |Matches a build version |
|[?<Code_Namespace>](Namespace.regex.txt) |Finds a Namespace (captures the Name and the Content between {}) |
|[?<Code_Region>](Region.regex.ps1) |Matches a #region #endregion pair. Returns the Name of the Region and the Content.<br/>|[generator](Region.regex.ps1)|
|[?<Code_SemanticVersion>](SemanticVersion.regex.txt)|Matches a Semantic Version. See [https://semver.org/](https://semver.org/). |
|Name |Description |Source |
|----------------------------------------------------|-----------------------------------------------------------------------------------------------------------------------------------------|---------------------------------|
|[?<Code_BuildVersion>](BuildVersion.regex.txt) |Matches a build version |
|[?<Code_Method>](Method.regex.txt) |Matches methods in most languages |[source](Method.regex.source.ps1)|
|[?<Code_Namespace>](Namespace.regex.txt) |Finds a Namespace (captures the Name and the Content between {}) |
|[?<Code_PackageVersion>](PackageVersion.regex.txt) |Matches a Package Name with a Version.<br/>Includes captures for Name, Version, Major, Minor, Patch, Build, and Prerelease, and Extension|
|[?<Code_Region>](Region.regex.ps1) |Matches a #region #endregion pair. Returns the Name of the Region and the Content.<br/> |[generator](Region.regex.ps1) |
|[?<Code_SemanticVersion>](SemanticVersion.regex.txt)|Matches a Semantic Version. See [https://semver.org/](https://semver.org/). |



1 change: 1 addition & 0 deletions RegEx/PowerShell/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ They are designed to work in _most_ scenarios and to offer an alternative way to
|----------------------------------------------------------|--------------------------------------------------------------------------------------------------------------|------------------------------------------|
|[?<PowerShell_Attribute>](Attribute.regex.txt) |Matches a PowerShell attribute declaration |
|[?<PowerShell_AttributeValue>](AttributeValue.regex.txt) |This expression extracts the key/value pairs from a PowerShell attribute body (the content within parenthesis)|
|[?<PowerShell_Function>](Function.regex.txt) |Matches PowerShell functions |
|[?<PowerShell_HelpField>](HelpField.regex.ps1) |Matches specific fields from inline help<br/> |[generator](HelpField.regex.ps1) |
|[?<PowerShell_Invoke_Variable>](Invoke_Variable.regex.txt)|Matches any time a variable is invoked (with the . or & operator) |[source](Invoke_Variable.regex.source.ps1)|
|[?<PowerShell_ParameterSet>](ParameterSet.regex.txt) |Matches PowerShell ParameterSets (in [Parameter] and [CmdletBinding] attributes) |[source](ParameterSet.regex.source.ps1) |
Expand Down
6 changes: 5 additions & 1 deletion SavedPatterns.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
### Irregular Patterns
Irregular includes 134 regular expressions
Irregular includes 138 regular expressions
|Name|Description|IsGenerator|
|:---|:----------|:----------|
|[ANSI_24BitColor](/RegEx/ANSI/24BitColor.regex.txt)|Matches an ANSI 24-bit color|False|
Expand All @@ -15,6 +15,7 @@ Irregular includes 134 regular expressions
|[ANSI_Hide](/RegEx/ANSI/Hide.regex.txt)|Matches ANSI Hide (aka conceal) Start or End|False|
|[ANSI_Invert](/RegEx/ANSI/Invert.regex.txt)|Matches ANSI Invert Start or End|False|
|[ANSI_Italic](/RegEx/ANSI/Italic.regex.txt)|Matches ANSI Italic Start or End|False|
|[ANSI_Link](/RegEx/ANSI/Link.regex.txt)|Matches ANSI Hyperlink|False|
|[ANSI_Note](/RegEx/ANSI/Note.regex.txt)|Matches an ANSI VT520 Note|False|
|[ANSI_Reset](/RegEx/ANSI/Reset.regex.txt)|Matches an ANSI Reset (this clears formatting)|False|
|[ANSI_Strikethrough](/RegEx/ANSI/Strikethrough.regex.txt)|Matches ANSI Strikethrough Start or End|False|
Expand All @@ -33,7 +34,9 @@ Irregular includes 134 regular expressions
|[CamelCaseSpace](/RegEx/CamelCaseSpace.regex.txt)|Matches where a CamelCaseSpace would be|False|
|[CNC_GCode](/RegEx/CNC/GCode.regex.txt)|Matches GCode Instructions|False|
|[Code_BuildVersion](/RegEx/Code/BuildVersion.regex.txt)|Matches a build version|False|
|[Code_Method](/RegEx/Code/Method.regex.txt)|Matches methods in most languages|False|
|[Code_Namespace](/RegEx/Code/Namespace.regex.txt)|Finds a Namespace (captures the Name and the Content between {})|False|
|[Code_PackageVersion](/RegEx/Code/PackageVersion.regex.txt)|Matches a Package Name with a Version.<br/>Includes captures for Name, Version, Major, Minor, Patch, Build, and Prerelease, and Extension|False|
|[Code_Region](/RegEx/Code/Region.regex.ps1)|Matches a #region #endregion pair. Returns the Name of the Region and the Content.|True|
|[Code_SemanticVersion](/RegEx/Code/SemanticVersion.regex.txt)|Matches a Semantic Version. See [https://semver.org/](https://semver.org/).|False|
|[Colon](/RegEx/Colon.regex.txt)|Matches a literal colon|False|
Expand Down Expand Up @@ -109,6 +112,7 @@ Irregular includes 134 regular expressions
|[PII_Unredacted_SSN](/RegEx/PII/Unredacted_SSN.regex.txt)|Matches Unredacted Social Security Numbers|False|
|[PowerShell_Attribute](/RegEx/PowerShell/Attribute.regex.txt)|Matches a PowerShell attribute declaration|False|
|[PowerShell_AttributeValue](/RegEx/PowerShell/AttributeValue.regex.txt)|This expression extracts the key/value pairs from a PowerShell attribute body (the content within parenthesis)|False|
|[PowerShell_Function](/RegEx/PowerShell/Function.regex.txt)|Matches PowerShell functions|False|
|[PowerShell_HelpField](/RegEx/PowerShell/HelpField.regex.ps1)|Matches specific fields from inline help|True|
|[PowerShell_Invoke_Variable](/RegEx/PowerShell/Invoke_Variable.regex.txt)|Matches any time a variable is invoked (with the . or & operator)|False|
|[PowerShell_ParameterSet](/RegEx/PowerShell/ParameterSet.regex.txt)|Matches PowerShell ParameterSets (in [Parameter] and [CmdletBinding] attributes)|False|
Expand Down
10 changes: 10 additions & 0 deletions docs/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,13 @@
## 0.7.7:

New Patterns:

* ?<Code_Method> : Matches methods in most languages (Fixes #171)
* ?<Code_PackageVersion> : Matches a package name and version (Fixes #172)
* ?<ANSI_Link> : Matches an ANSI Hyperlink (Fixes #173)

---

## 0.7.6:

* New-RegEx improvements:
Expand Down
4 changes: 2 additions & 2 deletions docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
<h2>Regular Expressions made Strangely Simple</h2>
<h3>A PowerShell module that helps you understand, use, and build Regular Expressions.</h3>
<h4>
<a href='https://github.com/StartAutomating/Irregular/releases/tag/v0.7.6'>v 0.7.6 </a>
<a href='https://github.com/StartAutomating/Irregular/releases/tag/v0.7.7'>v 0.7.7 </a>
</h4>
<a href='https://www.powershellgallery.com/packages/Irregular/'>
<img src='https://img.shields.io/powershellgallery/dt/Irregular' />
Expand Down Expand Up @@ -32,7 +32,7 @@ Once you understand some basics of that syntax, regular expressions become a lot
3. A Regex can have comments! ( # Like this in .NET ( or like (?#this comment) in ECMAScript ) ).
4. You don't have to do it all in one expression!

Irregular comes with 134 useful [named expressions](SavedPatterns.md), and lets you create more.
Irregular comes with 138 useful [named expressions](SavedPatterns.md), and lets you create more.

To see the expressions that ship with Irregular, run:

Expand Down
2 changes: 1 addition & 1 deletion docs/RegExQuickReference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
|.|any single character|
|+|one or more of the preceeding pattern|
|?|zero or more of the preceeding pattern|
|\\ | escape sequence or [character class](#CharacterClasses) or backreference|
|\\ | escape sequence or [character class](#characterclasses) or backreference|
|[*anyofthese*]|Any of these characters|
|[^ *notoneofthese* ]|matches any character that's isnt one of these characters|
|[start-end]|(matches this range)|
Expand Down
2 changes: 1 addition & 1 deletion docs/Regular_Expression_Quick_Reference.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
|.|any single character|
|+|one or more of the preceeding pattern|
|?|zero or more of the preceeding pattern|
|\\ | escape sequence or [character class](#CharacterClasses) or backreference|
|\\ | escape sequence or [character class](#characterclasses) or backreference|
|[*anyofthese*]|Any of these characters|
|[^ *notoneofthese* ]|matches any character that's isnt one of these characters|
|[start-end]|(matches this range)|
Expand Down
Loading

0 comments on commit 38633d5

Please sign in to comment.