Given that this string is a line from a file "test.txt":
"Two words more stuff here til the end of the line"
Can anyone help me with the correct regular expression sytax for the following code that will
1) identify the line in the file by its first two words
2) allow me to print off just the contents of the line that come AFTER the first two words and the large space (i.e. "more stuff..."?
What I've got does not seem to work. Thanks!
infile = open('test.txt', 'r')
linesin = infile.readlines()
for line in linesin:
pattobj = re.compile("Two\swords\s+\.+"
matchobj = pattobj.search(line)
if matchobj:
print matchobj.group()
"Two words more stuff here til the end of the line"
Can anyone help me with the correct regular expression sytax for the following code that will
1) identify the line in the file by its first two words
2) allow me to print off just the contents of the line that come AFTER the first two words and the large space (i.e. "more stuff..."?
What I've got does not seem to work. Thanks!
infile = open('test.txt', 'r')
linesin = infile.readlines()
for line in linesin:
pattobj = re.compile("Two\swords\s+\.+"
matchobj = pattobj.search(line)
if matchobj:
print matchobj.group()