title: PowerShell: Find Text between two Words
body: <p>I need to find out, if there are <code>maxThreads</code> and/or <code>maxConnections</code> configured in the <code>connector port 8080</code> of tomcat.</p>
  
  <p>example:</p>
  
  <pre><code>&lt;Connector port="8080" protocol="HTTP/1.1"
         maxThreads="600"
         maxConnections="3000"
             connectionTimeout="20000"
             redirectPort="443" /&gt;
  </code></pre>
  
  <p>I tried it with <code>regex</code> but poorly failed.</p>
  
  <pre><code>$file = Get-Content "D:\Program Files\Apache Software Foundation\Tomcat 7.0\conf\server.xml"
  $pattern = "(?&lt;=.*protocol=""HTTP/1.1"")\w+?(?=connectionTimeout=""20000"".*)"
  $Opts = [Regex]::Match($file, $pattern)
  </code></pre>
  
  <p>Thanks ahead</p>