View Single Post
Old 05-22-2007   #2 (permalink)
Brandon Shell


 
 

Re: split works much different than expected

Hopefully this will enlighten you a bit:
http://msdn2.microsoft.com/en-us/lib...ing.split.aspx

Maybe a regex would be better for you.

"Frank" <Frank@discussions.microsoft.com> wrote in message
news:AA3C2345-7E77-4C73-A7D9-F3E73B1F6790@microsoft.com...
> Hi,
>
> I am trying to get the error codes from a file but split seems to work
> much
> different than I expect. ie, my file error_log contains:
>
> cmd.exe exited on testserver with error code 1603.
>
> when I try to do a split ie.
>
> $testerr = get-content error_log | where($_ -match "error code"}
> if ($testerr){
> ($one,$two)=$testerr.split("error code")
> "one: $one, two: $two"
> }
>
> I get really strange output, like:
>
> one: ps, two: x . x : .......
>
> Can someone help with split?
>
> Thanks,
>


My System SpecsSystem Spec