Skip to content

Instantly share code, notes, and snippets.

@JimMoyle
Last active November 8, 2023 10:17
Show Gist options
  • Save JimMoyle/04268d182da744e48ebf2cad3b21c346 to your computer and use it in GitHub Desktop.
Save JimMoyle/04268d182da744e48ebf2cad3b21c346 to your computer and use it in GitHub Desktop.
Regex to Match a PowerShell cmdlet name or parameter in Pascal Case including Acronyms
$cmdletName -cmatch "^(?:[A-Z]{1,3}(?:[a-z0-9_])+)+[A-Z]{0,2}-(?:[A-Z]{1,3}(?:[a-z0-9_])+)+[A-Z]{0,2}$"
$parameterName -cmatch '^(?:[A-Z]{1,3}(?:[a-z0-9_])+)+[A-Z]{0,2}$'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment