Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.python > #78719 > unrolled thread
| Started by | Shiva <shivaji_tn@yahoo.com> |
|---|---|
| First post | 2014-10-05 17:08 +0000 |
| Last post | 2014-10-05 17:08 +0000 |
| Articles | 1 — 1 participant |
Back to article view | Back to comp.lang.python
This discussion starts older than the indexed window; earlier articles aren't shown. The article labeled Started by
below is the oldest one visible, not the original post.
Re: re search through a text Vs line Shiva <shivaji_tn@yahoo.com> - 2014-10-05 17:08 +0000
| From | Shiva <shivaji_tn@yahoo.com> |
|---|---|
| Date | 2014-10-05 17:08 +0000 |
| Subject | Re: re search through a text Vs line |
| Message-ID | <mailman.14614.1412528943.18130.python-list@python.org> |
OK,
Hi Dave,
I modified it as below and it works....(If there is a way to make this more
efficient please let me know)
By the way I am using Python 3.4
import sys
import re
def extract_names(filename):
path = '/home/LearnPython/exercises/'
fullfilename = path+filename
print('fullfilename: ',fullfilename)
fileextract = open(fullfilename,'r')
#line = fileextract.readlines()
#print(line)
for l in fileextract:
#print(l)
texts = re.search(r'\d\d\d\d', l)
if texts:
print(texts.group())
#print(texts.group())
#return texts.group()
fileextract.close()
extract_names('NOTICE.txt')
Thanks,
Shiva
Back to top | Article view | comp.lang.python
csiph-web