ArrayList Prints Numbers

Input Data:

(00:00) Pedro Del Mar & Beatsole - Pianophoria (Original Mix)
 http://goo.gl/L6jAk1 
 [Black Hole Recordings]

03:01 New World - Ushio (Original Mix) 
http://goo.gl/MQyTq7 
[Abora Recordings]

Powershell Code:

$readData = Get-Content "C:\Users\SomeUser\inputData - Alternate - 2.txt"
$ArrayList = New-Object System.Collections.ArrayList


function removeBrackets([string]$removeBrackets){


if($removeBrackets.Contains(":") -and ($removeBrackets.IndexOf(":")  -eq 2)){
           $subString = $removeBrackets.Substring(7-1);
           $ArrayList.Add($subString)


  }
elseif($removeBrackets.Contains(":") -and ($removeBrackets.IndexOf(":")  -eq 3)){ 
         $subString = $removeBrackets.Substring(7+1);
         $ArrayList.Add($subString)

     }

}

for($i=0; $i -le $readData.Length; $i++){


     removeBrackets($readData[$i])


}

for($a=0; $a -le $ArrayList.Count; $a++){

   Write-Output $ArrayList[$a]
}

Output:

0
1
Pedro Del Mar & Beatsole - Pianophoria (Original Mix)
New World - Ushio (Original Mix)

Problem:

I created a script that filters out data from a text file. It removes the HTTP links and times from the tracks. It then adds the string to an Array List

Why does printing the Array List produce the 0,1? How do I prevent that from happening?

Answers


The ArrayList.Add method always returns the index of the new item that you add:

PS > $ArrayList = New-Object System.Collections.ArrayList
PS > $ArrayList.Add('a')
0
PS > $ArrayList.Add('b')
1
PS >

You can suppress this output by either casting to [void]:

PS > $ArrayList = New-Object System.Collections.ArrayList
PS > [void]$ArrayList.Add('a')
PS >

or by redirecting the output to $null:

PS > $ArrayList = New-Object System.Collections.ArrayList
PS > $ArrayList.Add('a') > $null
PS > 

Need Your Help

Include several HTML pages with JavaScript into one PHP page

php javascript jquery html include

Earlier I asked about fixing the clock below and BAM! The solution was nearly instantaneous. Since then I have successfully added several of these clocks to a single PHP page. One for Tokyo, one for

Using connect vhost to serve multiple express.js apps

javascript node.js express connect vhosts

I want to use connect's vhost functionality to deploy several express.js apps to my dev vps. Here is my server.js file that is supposed to send requests to the appropriate place:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.