Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #78715 > unrolled thread

re search through a text Vs line

Started byShiva <shivaji_tn@yahoo.com>
First post2014-10-05 09:36 +0000
Last post2014-10-05 09:36 +0000
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  re search through a text Vs line Shiva <shivaji_tn@yahoo.com> - 2014-10-05 09:36 +0000

#78715 — re search through a text Vs line

FromShiva <shivaji_tn@yahoo.com>
Date2014-10-05 09:36 +0000
Subjectre search through a text Vs line
Message-ID<mailman.14612.1412501826.18130.python-list@python.org>
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

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web