Skip to content

Commit

Permalink
feat: Language Command IsMatch (Fixes #636)
Browse files Browse the repository at this point in the history
  • Loading branch information
James Brundage committed Nov 11, 2023
1 parent fb06a64 commit 8cd1465
Showing 1 changed file with 14 additions and 0 deletions.
14 changes: 14 additions & 0 deletions Types/Language.Command/IsMatch.ps1
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@


$regexPatterns = @(foreach ($attr in $this.ScriptBlock.Attributes) {
if ($attr -isnot [ValidatePattern]) { continue }
[Regex]::new($attr.RegexPattern, $attr.Options, '00:00:05')
})

foreach ($arg in $args) {
foreach ($regexPattern in $regexPatterns) {
if ($regexPattern.IsMatch($arg)) { return $true }
}
}

return $false

0 comments on commit 8cd1465

Please sign in to comment.