title: powershell extract text between two strings
body: <p>I know this question has been asked before but I can't get any of the answers I have looked at to work. I have a JSON file which has thousands of lines and want to simply extract the text between two strings every time they appear (which is a lot).</p>
  
  <p>As a simple example my JSON would look like this:</p>
  
  <pre><code>    "customfield_11300": null,
      "customfield_11301": [
        {
          "self": "xxxxxxxx",
          "value": "xxxxxxxxx",
          "id": "10467"
        }
      ],
      "customfield_10730": null,
      "customfield_11302": null,
      "customfield_10720": 0.0,
      "customfield_11300": null,
      "customfield_11301": [
        {
          "self": "zzzzzzzzzzzzz",
          "value": "zzzzzzzzzzz",
          "id": "10467"
        }
      ],
      "customfield_10730": null,
      "customfield_11302": null,
      "customfield_10720": 0.0,
  </code></pre>
  
  <p>So I want to output everything between "customfield_11301" and "customfield_10730":</p>
  
  <pre><code>      {
          "self": "xxxxxxxx",
          "value": "xxxxxxxxx",
          "id": "10467"
        }
      ],
        {
          "self": "zzzzzzzzzzzzz",
          "value": "zzzzzzzzzzz",
          "id": "10467"
        }
      ],
  </code></pre>
  
  <p>I'm trying to keep it as simple as possible - so don't care about brackets being displayed in the output.</p>
  
  <p>This is what I have (which outputs way more than what I want):</p>
  
  <pre><code>$importPath = "todays_changes.txt"
  $pattern = "customfield_11301(.*)customfield_10730"
  
  $string = Get-Content $importPath
  $result = [regex]::match($string, $pattern).Groups[1].Value
  $result
  </code></pre>