I read a file having the following text
this is::b(test file).
extra this is::another(test file).
this is::a(test file)
I am able to read the file and write it in another file.I want to capture the word after
this is:: and before '(' i.e 'b' from the first line and 'a' from the 3rd line and store it in a list and nothing from the 2nd line since it has extra word before 'this is' I tried using the Regular expression:
for item in lines:
print(item)
fw.write(item)
found=None
found=(re.search('this is::(.+?)[)]',y).group(1)
where y= string read from the file
y=''.join(lines)
But it is capturing only 'b' and adding the new line after each line.
Can someone please suggest how should I go about achieving it. Expected File:
this is::b(test file).
An extra line:b
extra this is:another(test file).
this is::a(test file).
An extra line:a