title: Regex IF condition
body: <p>I'm looking for a way to filter new IP-Addresses in my host file.
  I created a script which updates my host file every time when I call it with data from the matrix enterprise manager. It works fine. But I have to find a solution that only 10.XX.XX.XX or 172.XX.XX.XX addresses are allowed to update.</p>
  
  <pre><code>Param(
    $newHost = $args[0],
    $newIP = $args[1]
  )
  
  $SourceFile = "hosts"
  $Match = "$newHost"
  
  (Get-Content $SourceFile) | % {if ($_ -notmatch $Match) {$_}} | Set-Content $SourceFile
  
  Start-Sleep -Seconds 1
  
  $tab = [char]9
  $enter = $newIP + $tab + $newHost
  
  if ($newIP XXXX)  #--&gt; here should be a regex if condition... no clue how it works..
  
  $enter | Add-Content -Path hosts
  </code></pre>