About 15,500 results
Open links in new tab
  1. Python String replace () Method - W3Schools

    Definition and Usage The replace() method replaces a specified phrase with another specified phrase. Note: All occurrences of the specified phrase will be replaced, if nothing else is specified.

  2. string — Common string operations — Python 3.14.3 documentation

    1 day ago · By converting the value to a string before calling __format__(), the normal formatting logic is bypassed. Three conversion flags are currently supported: '!s' which calls str() on the value, '!r' which …

  3. Python String replace () Method - GeeksforGeeks

    Nov 17, 2025 · The replace () method returns a new string where all occurrences of a specified substring are replaced with another substring. It does not modify the original string because Python strings are …

  4. How to Replace a String in Python

    In this tutorial, you'll learn how to remove or replace a string or substring. You'll go from the basic string method .replace () all the way up to a multi-layer regex pattern using the sub () function from …

  5. Replace Strings in Python: replace (), translate (), and Regex

    May 4, 2025 · In Python, you can replace strings using the replace() and translate() methods, or with regular expression functions like re.sub() and re.subn(). Additionally, you can replace substrings at …

  6. Python String Replace: Complete Guide to str.replace () and Beyond

    Feb 9, 2026 · This guide covers every approach to string replacement in Python -- from the basic str.replace() to regex-powered re.sub(), character-level translate(), and practical patterns for real …

  7. Mastering `str.replace` in Python: A Comprehensive Guide

    Apr 19, 2025 · str.replace is a built-in method in Python's string class. It is used to replace occurrences of a specified substring with another substring within a given string.

  8. Python String replace () Method - PyTutorial

    Oct 18, 2024 · Learn how to use the Python string replace () method to replace parts of a string with new values. Explore examples and practical use cases of replace ().

  9. Python String.Replace() – Function in Python for Substring Substitution

    Jan 24, 2022 · In this article you'll see how to use Python's .replace() method to perform substring substiution. You'll also see how to perform case-insensitive substring substitution.

  10. Python String replace ()

    In this tutorial of Python Examples, we learned about string replace () method, and how to use this string replace () method to replace the occurrences of a substring with another string, with the help of well …