-
-
Notifications
You must be signed in to change notification settings - Fork 8
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
Also fixing aliases in templates and marking JavaScript as CaseSensitive
- Loading branch information
StartAutomating
authored and
StartAutomating
committed
Dec 6, 2023
1 parent
414da1e
commit eeb12c8
Showing
1 changed file
with
47 additions
and
0 deletions.
There are no files selected for viewing
47 changes: 47 additions & 0 deletions
47
Commands/Languages/JavaScript/JavaScript-Template-RegexLiteral.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
|
||
function Template.RegexLiteral.js { | ||
|
||
<# | ||
.SYNOPSIS | ||
Template for a JavaScript `function` | ||
.DESCRIPTION | ||
Template for a `function` in JavaScript. | ||
.EXAMPLE | ||
Template.RegexLiteral.js -Pattern "\d+" | ||
#> | ||
[Alias('Template.Regex.js')] | ||
param( | ||
# The pattern. | ||
[Parameter(ValueFromPipelineByPropertyName)] | ||
[Alias('Expression','RegularExpression','RegEx')] | ||
[string] | ||
$Pattern, | ||
|
||
# The regular expression flags | ||
[Alias('Flags')] | ||
[ValidateSet("d","hasIndices","g","global","i","ignoreCase","m","multiline","s","dotAll","u","unicode","v","unicodeSets","y","sticky")] | ||
[string[]] | ||
$Flag | ||
) | ||
|
||
process { | ||
$flag = foreach ($FlagString in $Flag) { | ||
if ($FlagString.Length -gt 1) { | ||
$valueList = @($MyInvocation.MyCommand.Parameters.Flag.Attributes.ValidValues) | ||
for ($valueIndex = 0; $valueIndex -lt $valueList.Length; $valueIndex++) { | ||
if ($FlagString -eq $valueList[$valueList]) { | ||
$valueList[$valueIndex - 1] | ||
} | ||
} | ||
} | ||
} | ||
@" | ||
/$pattern/$flag | ||
"@ | ||
} | ||
|
||
} | ||
|
||
|
||
|
||
|