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'
Using PowerShell newline in Command To add newline in PowerShell script command, use the` (backtick) character at the end of each line to break the command into multiple line.
In PowerShell, using Get-Content to skip first line of file, use Skip parameter with value to skip line.
In PowerShell and PowerShell ISE, it is also possible to use Shift + Enter at the end of each line for multiline editing (instead of standard backtick ` ).
To create a line break in JavaScript, use “<br>”.
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"
I think I found it. All you have to do is type in "`n" (WITH THE QUOTATION MARKS!)
Thanks!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With