Okay! Next question! smile

I need to split a string, which usually contains multiple lines, into an array, via a simple .Split() command in Powershell.

Easy enough. But...

I need to split on any/all of the following:
- A CRLF pair (0x0D followed by 0x0A)
- A LF only (0x0A)
- The literal string of ascii characters "\r\n" (i.e., not a CRLF but the actual ascii letters backslash, lowercase r, backslash, lowercase n)

The first two are easy in powershell:
Code:
$stackTraceLines = $stackTraceToParse.Split("`r`n").Split("`n")


That *seems* to work though I'm not 100 percent certain it's working as designed. I get output I like at least.

The last one is the problem. No matter what I type into the last Split command, it either doesn't split at all, or it splits on the letters r and n rather than the string "\r\n":
Code:
$stackTraceLines = $stackTraceToParse.Split("`r`n").Split("`n").Split('\r\n') 
$stackTraceLines = $stackTraceToParse.Split("`r`n").Split("`n").Split('\\r\\n') 
$stackTraceLines = $stackTraceToParse.Split("`r`n").Split("`n").Split('\\\r\\\n') 
$stackTraceLines = $stackTraceToParse.Split("`r`n").Split("`n").Split('\\\\r\\\\n') 
$stackTraceLines = $stackTraceToParse.Split("`r`n").Split("`n").Split('[\\r\\n]') 


Nothing is working. Does anyone know what is the correct syntax is here?

All my google searches are showing me how to split on CRLFs instead, because it's really hard to search on google for asking how to split on a LITERAL "\r\n".
_________________________
Tony Fabris