Reputation: 11
I have the following code:
import re
targetFile = open("test.txt").read()
print(re.search('(<\\/nesting_tag>)',targetFile))
The idea is I return everything between the . E.g. "Test" when Test. How can I return "Test" as opposed to <_sre.SRE_Match object; span=(56, 70), match=''>?
Upvotes: 1
Views: 38
Reputation: 4912
try this
print(re.search('(<\\/nesting_tag>)',targetFile).group())
Upvotes: 1