LoginSignup
1
0

More than 3 years have passed since last update.

Powershell 5.0 でアルファベットの範囲演算子の代替処理を実装する

Posted at

はじめに

Powershell 6.0 では、範囲演算子が拡張され、 'A'..'Z'とすると、ABC...XYZの結果を返すようになるそうです。

私が使っているPowershell 5.0で使いたい場合の実装をメモします。

環境

Powershell 5.0
※6.0の方は、標準で提供されているものを使用してください。

実装

範囲演算子の代替処理
#[byte][char]'A'
# -> 65
#[byte][char]'Z'
# -> 90

foreach ($num in 65..90) {
    $([char]$num)
}

実行すると、A~Zがずらーっと表示されます。

参考

Powershell 6.0 で範囲演算子が追加される件
https://blog.shibata.tech/entry/2015/12/03/000000

Powershellで文字をコードで扱う方法
https://hiros-dot.net/PowerShell/string/string06.htm

1
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
0