Skip to content

Commit 4c1b47f

Browse files
author
James Brundage
committed
Adding ?<PowerShell_Hashtable> ( Fixes #194 )
1 parent bf0ba9c commit 4c1b47f

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
$myName = ($MyInvocation.MyCommand.ScriptBlock.File | Split-Path -Leaf) -replace '\.source', '' -replace '\.ps1', '.txt'
2+
$myRoot = $MyInvocation.MyCommand.ScriptBlock.File | Split-Path
3+
4+
New-RegEx -Description "Matches a PowerShell Hashtable" -Comment "Starts with at sign" -LiteralCharacter '@' |
5+
New-regex -Pattern '?<BalancedCurlyBracket>' |
6+
Set-Content -Path (Join-Path $myRoot $myName) -Encoding UTF8 -PassThru
7+
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
# Matches a PowerShell Hashtable
2+
\@ # Starts with at sign
3+
(?<BalancedCurlyBracket>
4+
\{ # An open {
5+
(?> # Followed by...
6+
[^\{\}]+| # any number of non-bracket character OR
7+
\{(?<Depth>)| # an open curly bracket (in which case increment depth) OR
8+
\}(?<-Depth>) # a closed curly bracket (in which case decrement depth)
9+
)*?(?(Depth)(?!)) # until depth is 0.
10+
\} # followed by a }
11+
)
12+

0 commit comments

Comments
 (0)