Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78715
| From | Shiva <shivaji_tn@yahoo.com> |
|---|---|
| Subject | re search through a text Vs line |
| Date | 2014-10-05 09:36 +0000 |
| Newsgroups | comp.lang.python |
| Message-ID | <mailman.14612.1412501826.18130.python-list@python.org> (permalink) |
Hi,
I am doing a regular expression search for a year through a file.
fileextract = open(fullfilename,'r')
line = fileextract.read()
texts = re.search(r'1\d\d\d', line)
print(texts.group())
The above works.
However if I do:
fileextract = open(fullfilename,'r')
line = fileextract.readlines()
for l in line:
texts = re.search(r'1\d\d\d', line)
print(texts.group())
None is returned. Why is it not iterating through each line of the file and
doing a search? - It seems to return none.
Thanks,
Shiva
Back to comp.lang.python | Previous | Next | Find similar | Unroll thread
re search through a text Vs line Shiva <shivaji_tn@yahoo.com> - 2014-10-05 09:36 +0000
csiph-web