Related to a former question. I would like to know why the code:
import re
[w for w in g.split() if re.search('^..j..t..$', w)]
does not give an appropriate answer for a text g defined from a previous text file as:
f=open('text.txt')
g=f.read()
For example: take the text: "I would love to give my opinion about the White House, although nobody would listen." and write:
g='I would love t give my opinion about the White House, although nobody would listen.'
in this case when I type
[w for w in g.split() if re.search('^..t..g..$', w)]
the answer is a single '[ ]' and not '[although]' as expected.
Furthermore, can similar commands be executed for searching strings in that manner from a text file?