Created
April 29, 2015 10:16
-
-
Save kayasax/182cde4cd2c7300b006c to your computer and use it in GitHub Desktop.
Suppression de lignes vides après un split
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# some ways to remove empty lines when splitting strings | |
# for example | |
# $text = "Video Video Audio Audio VBI VBI" | |
# $text.Split() | |
# outputs this | |
# Video | |
# Video | |
# Audio | |
# Audio | |
# VBI | |
# VBI | |
# 1. using powershell -split as unary operator | |
-split $text | |
# 2. Using powershell -split operator (use regular expression) | |
$text -split '\s+' #Here, the \s represents whitespace characters, and the + matches one or more of them. | |
# 3. Filter not null elements | |
$text.split()| where {$_} | |
# 3. using the .net split method : | |
$text.split(" ",[System.StringSplitOptions]::RemoveEmptyEntries) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment