Freitag, 20. Februar 2009

ISE Extension basics: splitting text to lines

Finally I got the best way to split text to an array of lines. It is using $text -split "`r`n"



Improved thanks to Jaycul's comment.

1 Kommentar:

  1. Don't forget there's a STRING array overload for String.Split() -- not just a character array, so you can split on a string instead of a character array, or a regular expression:

    $text.Split([string[]]"`r`n", [StringSplitOptions]::None)

    It's actually more efficient unless you need the regular expression capability.

    AntwortenLöschen