Removing all occurences of a character from a string.

Miki Tebeka tebeka at cs.bgu.ac.il
Wed Sep 25 10:26:37 CEST 2002


Hello Sean,


> I have a string, say "'Hello World'", where Hello World is in single
> quotes(i.e., 'Hello World'). How can I remove the single quotes so that
> "'Hello World'" becomes "Hello World"?

import re
re.sub("'", "", "'Hello World'")

HTH.
Miki



More information about the Python-list mailing list