如何在PowerShell中断行?(How to break lines in PowerShell?)
我是PowerShell的全新功能,并且在循环中连接一个字符串,如果发生特殊情况,我应该插入一个换行符...我该怎么做?
基本上寻找相当于\n 。
$str = "" foreach($line in $file){ if($line -Match $review){ #Special condition $str += ANSWER #looking for ANSWER } #code..... }到目前为止我已经试过了
"\n" '\n' "\N" '\N' "\r" '\r' "\R" '\R' '`n' '`r' '-n' '-r'I am [completely new to PowerShell and] concatenating a string in a loop, if a special condition occurs I should insert a line break...how can I do this?
Basically looking for the equivalent of \n.
$str = "" foreach($line in $file){ if($line -Match $review){ #Special condition $str += ANSWER #looking for ANSWER } #code..... }So far I have tried
"\n" '\n' "\N" '\N' "\r" '\r' "\R" '\R' '`n' '`r' '-n' '-r'最满意答案
尝试`n ( 不是 '`n' )
有关转义字符的完整列表,请参阅:
Help about_Escape_character
代码应该是
$str += "`n"Try "`n" with double quotes. (not single quotes '`n' )
For a complete list of escaping characters see:
Help about_Escape_character
The code should be
$str += "`n"
更多推荐
发布评论