Hi all.Am trying to extract a group of words from a text file.but i dont get the expected result using regular expression.Here are my codes:
mytext.txt contains:
Group=1
Name=mattew
Sex=male
Age=25
Group=2
Name=John
Sex=Male
Age=19
When i try to get the group=1 i end up get everything below the group 1
import re
data=open('mytext.txt').read()
p=re.compile(r'Group: [0-9]\n{1}#.*$',re.S)
m=p.search(data)
print m.group()
I only want to extract a certain group and everything below it only.please how do i do this?