Writing string to a RichTextBox with the following code
$TextBox.text = "`r`n Some Text `r`n" + $TextBox.text
Under certain circumstances, I need to delete a specific line from the text. The problem, I manage to find and delete the line but the rest of the text moves only 1 line up instead of 2
$TextBox.text = (($TextBox.text -split "`n") | ? {$_ -notmatch 'WordToSearch'}) -join "`n"
As I said, it removes the line, but an unnecessary new line still remains. How can I remove it too without using array or other complicated way?
For example, this is how the text looks:
\\empty line row 1, some text \\empty line row 2, some text \\empty line
After my attempt of deleting row 1, it looks like this:
\\empty line \\empty line row 2, some text \\empty line
Expected:
\\empty line row 2, some text \\empty line