Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!proxad.net!feeder1-2.proxad.net!news.tele.dk!news.tele.dk!small.news.tele.dk!newsgate.cistron.nl!newsgate.news.xs4all.nl!post.news.xs4all.nl!not-for-mail Return-Path: X-Original-To: python-list@python.org Delivered-To: python-list@mail.python.org X-Spam-Status: OK 0.001 X-Spam-Evidence: '*H*': 1.00; '*S*': 0.00; 'subject:text': 0.05; 'returned.': 0.07; 'line:': 0.09; 'received:80.91': 0.09; 'received:80.91.229': 0.09; 'received:gmane.org': 0.09; 'received:list': 0.09; 'works.': 0.09; 'iterating': 0.16; 'line)': 0.16; 'message-id:@post.gmane.org': 0.16; 'none.': 0.16; 'received:80.91.229.3': 0.16; 'received:plane.gmane.org': 0.16; 'subject:search': 0.16; 'thanks,': 0.17; 'seems': 0.21; 'header :User-Agent:1': 0.23; 'file.': 0.24; 'header:X-Complaints-To:1': 0.27; 'file': 0.32; 'regular': 0.32; 'doing': 0.36; 'charset:us- ascii': 0.36; 'hi,': 0.36; 'skip:o 20': 0.38; 'to:addr:python- list': 0.38; 'to:addr:python.org': 0.39; 'skip:p 20': 0.39; 'received:org': 0.40; 'expression': 0.60; 'do:': 0.91 X-Injected-Via-Gmane: http://gmane.org/ To: python-list@python.org From: Shiva Subject: re search through a text Vs line Date: Sun, 5 Oct 2014 09:36:53 +0000 (UTC) Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Transfer-Encoding: 7bit X-Gmane-NNTP-Posting-Host: sea.gmane.org User-Agent: Loom/3.14 (http://gmane.org/) X-Loom-IP: 95.146.91.5 (Mozilla/5.0 (X11; Linux x86_64; rv:31.0) Gecko/20100101 Firefox/31.0) X-BeenThere: python-list@python.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: General discussion list for the Python programming language List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Newsgroups: comp.lang.python Message-ID: Lines: 26 NNTP-Posting-Host: 2001:888:2000:d::a6 X-Trace: 1412501826 news.xs4all.nl 2838 [2001:888:2000:d::a6]:55469 X-Complaints-To: abuse@xs4all.nl Xref: csiph.com comp.lang.python:78715 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