thanks for making me understand more on re. re is a confusing topic as i'm starting on python. > Date: Sat, 22 Jan 2011 16:55:37 -0800 > From: st...@alchemy.com > To: tc...@hotmail.com > CC: tutor@python.org > Subject: Re: [Tutor] Help on RE > > On Sun, Jan 23, 2011 at 12:38:10AM +0000, tee chwee liong wrote: > > 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? > > numbers = re.findall("\d+", line) > > The \d matches a digit character. \d+ matches one or more digit characters. > Nothing in your regex matches a sign character. You might want something like > [-+]\d+ > which would require either a - or + followed by digits. If you want the sign > to be optional, maybe this would work: > [-+]?\d+ > > > > > -- > Steve Willoughby | Using billion-dollar satellites > st...@alchemy.com | to hunt for Tupperware.
_______________________________________________ Tutor maillist - Tutor@python.org To unsubscribe or change subscription options: http://mail.python.org/mailman/listinfo/tutor