title: Failing to get Substring from Path in PowerShell
body: <p>There are these two given paths</p>
  <pre><code>$x = 'C:\temp\folder1\data' 
  $t = 'C:\temp\'   
  </code></pre>
  <p>Desired is to get '\folder1\data' to a new variable</p>
  <p>I tried</p>
  <pre><code>Select-String  -Path $x -Pattern $t
  </code></pre>
  <p>which ended in</p>
  <pre><code>Select-String: The string C:\temp\ is not a valid regular expression: Invalid pattern 'C:\temp\' at offset 8. Illegal \\ at end of pattern.
  </code></pre>
  <p>Also I tried to replace the backslash with a pipe symbol which ended in</p>
  <pre><code>Select-String: Cannot find path 'C:\|temp|folder1|data' because it does not exist.
  </code></pre>
  <p>This</p>
  <pre><code>$x -replace $t,&quot;&quot;
  </code></pre>
  <p>does bring back</p>
  <pre><code>||folder1|data
  </code></pre>
  <p>Which is close.
  How would I correctly extract a search string from a path string ins PS ?</p>