Can anyone explain the strange behavior with string.split given the following examples.
# produces output that appears to split on "n" rather than the newline character
(ls alias: | Out-String).Split("\n")
# produces output that appears to split on "r" or "n" rather than the windows newline characters
(ls alias: | Out-String).Split("\r\n")
# produces output where each item is separated by a newline
(ls alias: | Out-String).Split([environment]::NewLine)
# produces the desired result
(ls alias: | Out-String) -split "\n"
# or
(ls alias: | Out-String) -split "\r\n"
I understand the difference between "\r\n" and "\n". I'm having trouble with the difference between -split and .Split(). I can't seem to find an answer.