quick regex question
Matt Price
matt.price at utoronto.ca
Thu Oct 28 12:46:48 EDT 2004
hi folks,
this is surely trivial, but can'f figure it out. I wnat to replace:
'string with spaces'
with
'StringWithSpaces'
so I tried this:
s = 'string with spaces'
pat = ' (.)'
t = re.sub(pat, upper, s)
I know this isn't quite right, I expect it to return:
'String With Spaces'
instead I get an error:
t = re.sub(' (.)', upper, s)
Traceback (most recent call last):
File "<stdin>", line 1, in ?
File "/usr/lib/python2.3/sre.py", line 143, in sub
return _compile(pattern, 0).sub(repl, string, count)
File "/usr/lib/python2.3/string.py", line 64, in upper
return s.upper()
AttributeError: upper
what am I doing wrong?
matt
-------------------------------------------
Matt Price matt.price at utoronto.ca
History Department, University of Toronto
(416) 978-2094
--------------------------------------------
please don't use the following addresses: zeus at derailleur.org
aardvark at derailleur.org
More information about the Python-list
mailing list