RE: [Tutor] re question

2005-03-28 Thread Ertl, John
l would not strip out the charecter...I may try a bit harder to make it work just becouse it bugs me that you made it work. Thanks again John Ertl -Original Message- From: Kent Johnson Cc: tutor@python.org Sent: 3/27/05 2:31 PM Subject: Re: [Tutor] re question Jacob S. wrote: > Kent

Re: [Tutor] re question

2005-03-27 Thread Kent Johnson
Jacob S. wrote: Kent -- when pulling out just the numbers, why go to the trouble of splitting by "," first? Good question. It made sense at the time :-) Here is another way using re.findall(): >>> import re >>> s='Std Lvl: 850hPa, 1503m, 16.8C, 15.7C, 205 @ 11kts' >>> re.findall(r'[\d\.]

Re: [Tutor] re question

2005-03-27 Thread Jacob S.
Kent -- when pulling out just the numbers, why go to the trouble of splitting by "," first? import re pat = re.compile(r"[^\d.]*") t = """SigWind: 857hPa, , 21.0C, 20.1C, 210 @ 9kts SigWind: 850hPa±, , , , 205 @ 11kts Std Lvl: 850hPa, 1503m, 16.8C, 15.7C,

Re: [Tutor] re question

2005-03-26 Thread Kent Johnson
I don't know why this isn't working for you but this worked for me at a DOS console: >>> s='850hPa±' >>> s '850hPa\xf1' >>> import re >>> re.sub('\xf1', '*', s) '850hPa*' >>> import sys >>> sys.stdout.encoding 'cp437' and also in IDLE with a different encoding: >>> s='850hPa±' >>> s '850hPa\

[Tutor] re question

2005-03-24 Thread Ertl, John
All I have a string that has a bunch of numbers with the units attached to them. I want to strip off the units. I am using a regular expression and sub to do this. This works great for almost all of the cases. These are the type of lines: SigWind: 857hPa, , 21.0C, 20.1C, 210 @ 9