About 146,000 results
Open links in new tab
  1. How to remove specific substrings from a set of strings in Python ...

    May 22, 2016 · in Python strings a immutable. str.replace(old, new) returns a copy of the string with all occurrences of substring 'old' replaced by 'new'. Its result must be assigned to a new variable.

  2. python - How do I remove a substring from the end of a string …

    926 strip doesn't mean "remove this substring". x.strip(y) treats y as a set of characters and strips any characters in that set from both ends of x. On Python 3.9 and newer you can use the removeprefix …

  3. How can I remove everything in a string until a character (s) are seen ...

    Oct 15, 2015 · Say I have a string and I want to remove the rest of the string before or after certain characters are seen For example, all my strings have 'egg' in them: "have an egg please" "my eggs …

  4. How to remove all characters after a specific character in python?

    Dec 4, 2021 · I have a string. How do I remove all text after a certain character? (In this case ...) The text after will ... change so I that's why I want to remove all characters after a certain one.

  5. python - Remove a prefix from a string - Stack Overflow

    Jun 3, 2013 · Obviously (stupid me), because I have used lstrip wrongly: lstrip will remove all characters which appear in the passed chars string, not considering that string as a real string, but as "a set of …

  6. python - Most efficient way to remove multiple substrings from string ...

    Jun 2, 2015 · What's the most efficient method to remove a list of substrings from a string? I'd like a cleaner, quicker way to do the following: words = 'word1 word2 word3 word4, word5' replace_list = …

  7. regex - Remove Sub String by using Python - Stack Overflow

    The re.sub function takes a regular expresion and replace all the matches in the string with the second parameter. In this case, we are searching for all tags ('<.*?>') and replacing them with nothing ('').

  8. How to remove substring from a string in python?

    Sep 30, 2014 · How to remove substring from a string in python? Asked 11 years, 1 month ago Modified 11 years, 1 month ago Viewed 8k times

  9. Remove unwanted parts from strings in a column - Stack Overflow

    262 How do I remove unwanted parts from strings in a column? 6 years after the original question was posted, pandas now has a good number of "vectorised" string functions that can succinctly perform …

  10. python - Remove sub-string from beginning of string - Stack Overflow

    Nov 30, 2014 · FTR: the equivalent of - operator for strings is string.replace (), but as other people pointed out, it will replace all occurrences of the string, not just at the beginning: