與字母混合卸下數字假設我有一個字符串,如:從字符串
string = 'This string 22 is not yet perfect1234 and 123pretty but it can be.'
我想刪除任何數字這是用言語混合,如'perfect1234'
和'123pretty'
,但不'22'
從我的字符串,並得到一個輸出如下:
string = 'This string 22 is not yet perfect and pretty but it can be.'
有沒有辦法使用正則表達式或任何其他甲基做到這一點在Python OD?任何幫助,將不勝感激。謝謝!
用'''替換所有的'\ d +'' – Tushar
請看這裏:http://stackoverflow.com/questions/12851791/removing-numbers-from-string – danielhadar
似乎OP想要消除只是數字的一部分字,而不是字符串中的任何數字。 (單詞邊界事項) – Keozon