[Tutor] Regular expression on python
jarod_v6 at libero.it
jarod_v6 at libero.it
Mon Apr 13 14:29:07 CEST 2015
Dear all.
I would like to extract from some file some data.
The line I'm interested is this:
Input Read Pairs: 2127436 Both Surviving: 1795091 (84.38%) Forward Only Surviving: 17315 (0.81%) Reverse Only Surviving: 6413 (0.30%) Dropped: 308617 (14.51%)
with open("255.trim.log","r") as p:
for i in p:
lines= i.strip("\t")
if lines.startswith("Input"):
tp = lines.split("\t")
print re.findall("Input\d",str(tp))
So I started to find ":" from the row:
with open("255.trim.log","r") as p:
for i in p:
lines= i.strip("\t")
if lines.startswith("Input"):
tp = lines.split("\t")
print re.findall(":",str(tp[0]))
And I'm able to find, but when I try to take the number using \d not work. Someone can explain why?
How can extract the numbers from this row.?
thanks so much=
More information about the Tutor
mailing list