En Wed, 13 Jan 2010 02:12:31 -0300, Gontrand Trudau <[email protected]> escribió:

I have read the python doc pretty much, played around with python code, but unable to get back my "string" after made my replacement with python RE

Here my string :

['[email protected] ;[email protected] ;name, firstname ;info;2010-01-01T00:00:00']

My objective is to remove all the white space except the one between the name and the firstname, that is OK.

Is it enough to remove all whitespace preceding a ';'?

py> text = "[email protected]                                  ;[email protected]
;name, firstname ;info;2010-01-01T00:00:0
0"
py> import re
py> re.sub('\s+;', ';', text)
'[email protected];[email protected];name, firstname;info;2010-01-01T00:00:00'

I would just like to be able to do something like that :

print match_obj

and have the result of the modification I just did :

[email protected]','[email protected]','name, firstname','info','2010-01-01T00:00:00

Those single quotes are confusing -- they aren't in the original string as you posted it... Apart from that, my solution worked fine in this example.

--
Gabriel Genellina

--
http://mail.python.org/mailman/listinfo/python-list

Reply via email to