Skip to content

Commit

Permalink
feat: Template.RegexLiteral.js ( Fixes #813, Fixes #815 )
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.
47 changes: 47 additions & 0 deletions Commands/Languages/JavaScript/JavaScript-Template-RegexLiteral.ps1
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
"@
}

}




0 comments on commit eeb12c8

Please sign in to comment.