我正在尝试交换字符串中的两个单词。我目前有一个 txt 文件,其中有一列用户格式为 last.first
。我如何将它交换为 first.last
?
最佳答案
-split
字符串并连接:
$Last,$First = "Lastname.Firstname" -split '\.'
$newString = "$First.$Last"
或使用-replace
重新排列两者:
"Lastname.Firstname" -replace '(\w+)\.(\w+)','$2.$1'
关于powershell - 在文本文件中交换 last.first 到 first.last,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38399360/