title: How can I extract text from a file using regex?
body: <p>Hi I'm looking for a way to extract a part of a text file with Python using a Regex:
  here is my code:</p>
  
  <pre><code>    texfile=open("texte.txt", "r")
          for line in texfile:
              if re.match("^text(.*)", line):
                 print line,
  </code></pre>
  
  <p>I'm seaching for the text following the word text until it reaches the end of paragraph or when it reach a white space,but my code return just the words which follow the word "text" on 1 line.</p>
  
  <p>For Example :</p>
  
  <pre><code>bla bla hhhhhhhh text bla blajjjjjjjjjjjjjjjjjjjjj
  hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
  ffff
  </code></pre>
  
  <p>Must return :</p>
  
  <pre><code>bla blajjjjjjjjjjjjjjjjjjjjj
  hhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhhh
  ffff
  </code></pre>
  
  <hr>
  
  <p>thank you I tried all your codes but no one works as I want:I want now to render it simple,extract the stream which follow  a certain "text" until it reach a blank line:                         </p>
  
  <pre><code>          text
      sssssssssssssssss
       ssssssss
      kkkk
      lllmmm
  
      kkkk
  
     ;must return 
      sssssssssssssssss
      ssssssss
      kkkk
      lllmmm
      ;because of the blank line
  </code></pre>