Skip to content

Instantly share code, notes, and snippets.

@Nora-Ballard
Created February 15, 2014 13:20
Show Gist options
  • Save Nora-Ballard/9019236 to your computer and use it in GitHub Desktop.
Save Nora-Ballard/9019236 to your computer and use it in GitHub Desktop.
function Get-AlphaRange([string]$Range)
{
$Alphabet = @('a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z')
$AlphabetIndex = @{'a' = 0 ;'b' = 1 ;'c' = 2 ;'d' = 3 ;'e' = 4 ;'f' = 5 ;'g' = 6 ;'h' = 7 ;'i' = 8 ;'j' = 9 ;'k' = 10 ;'l' = 11 ;'m' = 12 ;'n' = 13 ;'o' = 14 ;'p' = 15 ;'q' = 16 ;'r' = 17 ;'s' = 18 ;'t' = 19 ;'u' = 20 ;'v' = 21 ;'w' = 22 ;'x' = 23 ;'y' = 24 ;'z' = 25}
if ($Range -match '[a-z]\.{2}[a-z]')
{
$RangeStart = $AlphabetIndex[$Range.split('..')[0]]
$RangeEnd = $AlphabetIndex[$Range.split('..')[2]]
if ($RangeStart -lt $RangeEnd)
{
$RangeStart..$RangeEnd | %{ Write-Output $Alphabet[$_]}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment