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
[email protected] | to hunt for Tupperware.
_______________________________________________
Tutor maillist - [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor