[Tutor] Help on RE

tee chwee liong tcl76 at hotmail.com
Sun Jan 23 01:53:49 CET 2011


thanks it works!! :) 
 
> Date: Sat, 22 Jan 2011 19:51:35 -0500
> Subject: Re: [Tutor] Help on RE
> From: japhy at pearachute.com
> To: tcl76 at hotmail.com
> CC: tutor at python.org
> 
> it's a bug in your regex - you want something like "-?\d+"
> 
> - japhy
> 
> On Sat, Jan 22, 2011 at 7:38 PM, tee chwee liong <tcl76 at hotmail.com> wrote:
> > 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
> >
> > _______________________________________________
> > Tutor maillist  -  Tutor at python.org
> > To unsubscribe or change subscription options:
> > http://mail.python.org/mailman/listinfo/tutor
> >
> >
 		 	   		  
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20110123/0218ab5a/attachment-0001.html>


More information about the Tutor mailing list