About 301,000 results
Open links in new tab
  1. 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 …

  2. 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.

  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. 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 …

  5. 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 ('').

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

    May 24, 2009 · 0 Yet another way to remove all characters after the occurrence of a character in a string (assume that you want to remove all characters after the final '/').

  7. 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 = …

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

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

  9. How can I remove a substring from a given String? - Stack Overflow

    Oct 15, 2011 · static String replacePattern(String source, String regex, String replacement) Replaces each substring of the source String that matches the given regular expression with the given …

  10. Remove substring only at the end of string - Stack Overflow

    Note that endswith can also take a tuple of suffixes to look for. If someone passes a tuple as the suffix with this function, you'll get the wrong result. It will check a list of strings but remove the length of the …