How to remove all characters before a specific character in Python

0 votes
I want to remove all characters before a designated character or set of characters. For example :

intro = "<>I'm Tom."
 

Now What to do if I want to remove the <> before I'm ?
Feb 27, 2019 in Python by ana1504.k
• 7,910 points
9,744 views

1 answer to this question.

0 votes

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

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

Hope this will help!

To learn more, go for Python Master course today.

Thank!

answered Feb 27, 2019 by SDeb
• 13,300 points

Related Questions In Python

0 votes
1 answer

How to Remove specific characters from a string in Python?

Strings in Python are immutable (can't be changed). Because ...READ MORE

answered Jan 5, 2021 in Python by Gitika
• 65,910 points
681 views
+1 vote
2 answers

How to print first character of each word in upper case of a string in Python

class Solution:     def firstAlphabet(self, s):             self.s=s              k=''              k=k+s[0]              for i in range(len(s)):                     if ...READ MORE

answered Oct 28, 2020 in Python by Anurag
11,772 views
0 votes
1 answer

How to change one character in a string in Python?

Python strings are immutable, you change them ...READ MORE

answered Dec 4, 2018 in Python by Nymeria
• 3,560 points
1,062 views
0 votes
1 answer

How to check if a string ends with a character in python?

You can use the endswith method. It checks ...READ MORE

answered Apr 5, 2019 in Python by Srisha
2,632 views
0 votes
1 answer

How to get the ASCII values of a character in python?

You can get the ASCII value of ...READ MORE

answered Aug 23, 2020 in Python by Sajetha Selva
9,036 views
0 votes
1 answer

How to remove all of the data in a table using Django?

Hello @kartik, Inside a manager: def delete_everything(self): ...READ MORE

answered Aug 12, 2020 in Python by Niroj
• 82,880 points
3,776 views
0 votes
1 answer

How to remove a file using the OS module in Python?

Hi@akhtar, In Python, you can use the os. remove() method to remove ...READ MORE

answered Oct 18, 2020 in Python by MD
• 95,440 points
862 views
0 votes
1 answer

How to Reverse a list in Python

You can use the reversed function in ...READ MORE

answered Sep 29, 2018 in Python by SDeb
• 13,300 points
645 views
+1 vote
1 answer

How to Profile a script in Python

Python includes a profiler called cProfile. It ...READ MORE

answered Nov 21, 2018 in Python by SDeb
• 13,300 points
1,441 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP