title: How can I remove a number from a list of strings and find unique instances?
body: <p>Our product consists of multiple WCF services that log some data to CSV files. Each service writes to its own set of files, where the files are named using a sequence number. For example:</p>
  
  <pre><code>Product.ServiceA1.csv
  Product.ServiceA2.csv
  Product.ServiceA3.csv
  Product.ServiceB1.csv
  Product.ServiceB2.csv
  Product.ServiceB3.csv
  </code></pre>
  
  <p>The files are all written to a common folder, <code>D:\Product\log</code>.</p>
  
  <p>I'm writing a script to process all the files for each service, and want to identify the results by service name, like so:</p>
  
  <pre><code>ServiceA: 25
  ServiceB: 30
  </code></pre>
  
  <p>I've come up with the following PowerShell code to get me a list of the distinct service names, but was wondering if anyone has a better way.</p>
  
  <pre><code># Get a list of all the file names; remove the 'Product' prefix and CSV file
  # extension so we get just the base name.
  $services = get-childitem $logFiles -Name | foreach { $_.Split(".")[1]}
  
  # Remove all the sequence numbers and get a list of the unique names.
  $services = [regex]::replace($services,'\d{1,3}','').split(" ") | get-unique
  </code></pre>
  
  <p>Thanks :)</p>