Saroekin Saroekin - 2 years ago 96
Python Question

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

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

intro = "<>I'm Tom."

Now I'd like to remove the
(or more specifically,
). Any suggestions?

Answer Source

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

re.sub(r'.*I', 'I', stri)
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download