[Tutor] Regular expression

jarod_v6 at libero.it jarod_v6 at libero.it
Tue Sep 23 11:40:25 CEST 2014


Hi there!!

I need to read this file:

pippo.count :
 10566 ZXDC
   2900 ZYG11A
   7909 ZYG11B
   3584 ZYX
   9614 ZZEF1
  17704 ZZZ3


This file present a use space on the begin then they have a number and the a 
word.
 p =re.compile("\s+\d+")
with open("pippo.count") as p:
    for i in p:
        lines =i.rstrip("\n").split("\t")
        print t.findall(str(lines))
out:

['    994']
['  10428']
['   1810']
['   4880']
['   8905']



How can extract only the number and the work in array? Thanks for any help
jarod


More information about the Tutor mailing list