1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
$result = "" Get-Content "f.txt" -Encoding default | ForEach-Object{ switch -Regex($_) { "([A-Z]|\-)50([A-Z]|\b)" {$result += $_ + ",50`n"; continue} "([A-Z]|\-)65([A-Z]|\b)" {$result += $_ + ",65`n"; continue} "([A-Z]|\-)80([A-Z]|\b)" {$result += $_ + ",80`n"; continue} "([A-Z]|\-)100([A-Z]|\b)" {$result += $_ + ",100`n"; continue} default {$result += $_ + ",不一致`n"} } } # echo $result $result | Out-File out.txt -Encoding default # >でも代替可能。 # Set-Content -path "out.txt" -value $result |