text file contains
paragraph 1:
01 internet 1
02 intranet 2
paragraph 2:
03 internet 1
04 intranet 2
paragraph 3:
05 internet 1
06 intranet 2
paragraph 4:
07 internet 1
08 intranet 2
I wanted to find intranet 2 in paragraph 2 using python.
This is what I have so far:
file = open( "c:\file.txt", "r" ).readlines()
var = raw_input("enter the value")
var1 = "paragraph 1:"
for line in file:
if re.search(var1, line,re.IGNORECASE):
print re.search(var, line,re.IGNORECASE)
print "found", line
count=line for line in file:
if re.search(var, line,re.IGNORECASE):
print "value=", line
Assuming you only want to search in the specified section this should work:
If the string is not found in the specified section it will show