stupid newbie question about string and re
Steve Holden
sholden at holdenweb.com
Fri Jan 18 10:15:48 EST 2002
Whoops. Omitted something from the previous posting.
...
You have accidentally supplied a string:
>>> string.upper("\\2")
'\\2'
>>>
Because this string contains a backslash (just one: the interpreter is
escaping it to give something that can be used in a program) followed by a
digit, re.sub() treats it as meaning "group 2 from the match object", so you
get the lower-case letter your patter detected after the space. Let's try
using a function instead
...
Sorry 'bout that.
regards
Steve
--
Consulting, training, speaking: http://www.holdenweb.com/
Python Web Programming: http://pydish.holdenweb.com/pwp/
More information about the Python-list
mailing list