title: In Python, how can I find a block of text in a file?
body: <p>I have a file that is in ASCII format, and I want to find a block of text surrounded by brackets, and get information from that file. The blocks look like this:</p>
  
  <pre><code>"material" "DmeMaterial"
  {
      "id" "elementid" "12af09eb-3a16-42a9-93eb-a9081a056d6d"
      "name" "string" "BodyParts_diffuse"
      "mtlName" "string" "models/characters/background/punk_01/BodyParts_diffuse"
  }
  </code></pre>
  
  <p>I can load up the file and the data prints out fine in the console with this code:</p>
  
  <pre><code>filePath = "F:\SteamLibrary\SteamApps\common\SourceFilmmaker\content_custom\mod_dmx\material_test.dmx"
  
  with open(filePath, "r+") as f:
      data = f.read()
      print data
      f.close()
  </code></pre>
  
  <p>But I want to crawl through the text and find "material" "DmeMaterial" then grab the information in between the brackets (specifically mtlName and name.) It's a bunch of complicated steps in my mind and I'm hoping someone can help me out or guide me in the right path</p>