[Tutor] Help on RE

tee chwee liong tcl76 at hotmail.com
Sun Jan 23 01:38:10 CET 2011


hi, 
 
i have a set of data and using re to extract it into array. however i only get positive value, how to extract the whole value including the -ve sign? 
For eg: 
 
Platform: PC
Tempt : 25
TAP0 :0
TAP1 :1
+++++++++++++++++++++++++++++++++++++++++++++
Port Chnl Lane EyVt EyHt
+++++++++++++++++++++++++++++++++++++++++++++
0  1  1  75  55
0  1  2  10 35
0  1  3  25 35 
0  1  4  35 25
0  1  5  10 -1
+++++++++++++++++++++++++++++++++++++++++++++
Time: 20s
 
When i run my code, i get 1 instead of -1 in the last line. here is my code. pls advise. i'm using Python 2.5 and Win XP. tq
##code###
import re
file = open("C:/Python25/myscript/plot/sampledata.txt", "r")
x1 = []
y1 = []
y2 = []
for line in file:
    numbers = re.findall("\d+", line)
    print numbers 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110123/bacd7bb4/attachment.html>


More information about the Tutor mailing list