powershell 置換

powershellで置換するサンプルです。

単純な文字列の置換

$str = '1234567890'

Write-Host ('置換前:' + $str)

# 456 を ABC に置換
$str = $str.Replace('456', 'ABC')

Write-Host ('置換後:' + $str)

正規表現を含む文字列の置換

$str = 'ABC	DEF'

Write-Host ('置換前:' + $str)

# スペース を ハイフン(-) に置換
$str = $str.Replace('\t', '-')

Write-Host ('置換後:' + $str)


Bookmark this on Yahoo Bookmark
Bookmark this on Google Bookmarks
Share on LinkedIn
LINEで送る
Pocket