-
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathIrregular.psm1
37 lines (29 loc) · 2.04 KB
/
Irregular.psm1
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
. $psScriptRoot\Get-RegEx.ps1
. $psScriptRoot\Export-RegEx.ps1
. $psScriptRoot\Import-RegEx.ps1
. $psScriptRoot\Remove-RegEx.ps1
. $psScriptRoot\Set-RegEx.ps1
. $psScriptRoot\Show-RegEx.ps1
. $psScriptRoot\Use-RegEx.ps1
. $psScriptRoot\Write-RegEx.ps1
Import-RegEx
foreach ($k in $script:_RegexLibrary.Keys) {
Set-Alias -Name "?<$k>" -Value Use-RegEx
}
$MyInvocation.MyCommand.ScriptBlock.Module.OnRemove = {
if ($script:_RegexTempModules -and $script:_RegexTempModules.Count) {
@($script:_RegexTempModules) | Remove-Module
}
}
$MyInvocation.MyCommand.ScriptBlock.Module |
Add-Member NoteProperty Splicers @{
'\?\<(?<Name>\w+)\>' = {
$out = "[Regex]::new(@'" + [Environment]::NewLine + (
Get-RegEx -Name $input.name |
Select-Object -ExpandProperty Pattern) + "'@, 'IgnoreCase,IgnorePatternWhitespace')"
$out
}
}
Set-Alias ?<> Write-RegEx
Set-Alias ?<.> Use-Regex
Export-ModuleMember -Function *-* -Alias *