Finding the "a" string in file within a block for one time using python
<p>I have a file contains 3 blocks 
Block1:
a
Block2:
a
Block3:
a 
I wanted to search "block1:" a string using python 
I have done code for Searching block1 : and a string but it is giving all the a </p>

<pre><code>file = open( "c:\Textfile.txt", "r" ).readlines()
var=raw_input("enter the value")
var1="// Block1:"
for line in file:
    if re.search(var1,line,re.IGNORECASE):
        print re.search(var,line,re.IGNORECASE)
        print "found",line
        for line in file:
            if re.search(var,line,re.IGNORECASE):
                print "value=",line
</code></pre>
