How to remove all characters before a specific character in Python?

后端 未结 9 978
醉梦人生
醉梦人生 2020-11-28 08:37

I\'d like to remove all characters before a designated character or set of characters (for example):

intro = \"<>I\'m Tom.\"

Now I\'d

9条回答
  •  余生分开走
    2020-11-28 09:22

    Use re.sub. Just match all the chars upto I then replace the matched chars with I.

    re.sub(r'^.*?I', 'I', stri)
    

提交回复
热议问题