Quantcast
Channel: PowerShell.org » All Posts
Viewing all articles
Browse latest Browse all 13067

Reply To: string manipulation

$
0
0

hi,

If you love to hate regex :-) (sorry Dave), this also works:


$name = $text -split [environment]::NewLine | foreach { if($_.startswith("Name")){$_.split(":")[1]} }
$name

or


$name = $text -split "`n" | foreach { if($_.startswith("Name")){$_.split(":")[1]} }
$name


Viewing all articles
Browse latest Browse all 13067

Trending Articles