title: pull text between characters
body: <p>How do I pull text between two words? I know regex can do this and I have been looking around but the code I try just does not work for me at all...as clueless as a brick with regex...so probably am doing it totally wrong...</p>
  
  <p>I have a text file and want to query whatever is displayed between these text strings:</p>
  
  <blockquote>
    <p>[Problem Devices]</p>
    
    <p>Device    PNP Device ID   Error Code  </p>
    
    <p>[USB]</p>
  </blockquote>
  
  <p>I tried doing this but getting no where!</p>
  
  <pre><code>$devices = Get-Content c:\temp\dev.txt | out-string [regex]::match($devices,'(?&lt;=\&lt;Problem Devices\&gt;).+(?=\&lt;USB\&gt;)',"singleline").value.trim()
  
  You cannot call a method on a null-valued expression.
  At line:1 char:141
  + $devices = Get-Content c:\temp\dev.txt | out-string [regex]::match($devices,'(?&lt;=\&lt;Problem Devices\&gt;).+(?=\&lt;USB\&gt;)',"
  singleline").value.trim &lt;&lt;&lt;&lt; ()
      + CategoryInfo          : InvalidOperation: (trim:String) [], RuntimeException
      + FullyQualifiedErrorId : InvokeMethodOnNull
  </code></pre>