No. Regular expressions in Python are handled by the re module.

article = re.sub(r'(?is)</html>.+', '</html>', article)

In general:

str_output = re.sub(regex_search_term, regex_replacement, str_input)
Answer from Ignacio Vazquez-Abrams on Stack Overflow
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-regex-replace-captured-groups
Python Regex: Replace Captured Groups - GeeksforGeeks
July 23, 2025 - Regex is supported in almost all major programming languages, and in Python, the `re` module provides an extensive set of functionalities for regex operations. This article dives into one of the crucial aspects of regex in Python: Regex Groups, and demonstrates how to use `re.sub()` for group replacement with practical examples.
🌐
PYnative
pynative.com › home › python › regex › python regex replace pattern in a string using re.sub()
Python Regex Replace Pattern in a string using re.sub()
July 19, 2021 - Python's regex offers sub() the subn() methods to search and replace occurrences of a regex pattern in the string with a substitute string.
🌐
Python documentation
docs.python.org › 3 › library › re.html
re — Regular expression operations — Python 3.14.7 ...
Source code: Lib/re/ This module provides regular expression matching operations similar to those found in Perl. Both patterns and strings to be searched can be Unicode strings ( str) as well as 8-...
🌐
PythonTest
pythontest.com › python › regex-search-replace
Python regex Search and Replace Examples | PythonTest
I think the most basic form of a search/replace script in python is something like this: import fileinput import re for line in fileinput.input(): line = re.sub('foo','bar', line.rstrip()) print(line) The fileinput module takes care of the stream verses filename input handling. The re (regex, ...
🌐
EDUCBA
educba.com › home › software development › software development tutorials › python string tutorial › python regex replace
Python regex replace | Learn the Parameters of Python regex replace
May 13, 2024 - In Python, we use replace() function ... the entire string; hence to do this, we use regular expression which provides “re” module and to replace part of the string we use sub() function as we saw how simple it is to use this ...
Address: Unit no. 202, Jay Antariksh Bldg, Makwana Road, Marol, Andheri (East),, 400059, Mumbai
🌐
Index.dev
index.dev › blog › regex-advanced-string-replacement-python
Python Regex Replace: How to Replace Strings Using re Module
The re.sub() function is the primary tool for performing string replacements with regex in Python. It allows you to specify a regex pattern to search for, a replacement string, and the target string where the replacement will occur.
Find elsewhere
🌐
Note.nkmk.me
note.nkmk.me › home › python
Replace Strings in Python: replace(), translate(), and Regex | note.nkmk.me
May 4, 2025 - Use the | operator to match multiple patterns. Each pattern may include special regex characters or literal substrings. This allows you to replace different substrings with the same string.
🌐
Medium
medium.com › @wepypixel › complete-python-regex-replace-guide-using-re-sub-pypixel-9b30b2604d7a
Complete Python Regex Replace Guide using re.sub() | PyPixel | by Stilest | Medium
December 8, 2023 - The re.sub() method in Python provides powerful search and replace functionality using regular expressions. The regex replace works by specifying the string to modify, defining a regex pattern to match against, and providing a replacement substring.
🌐
Dive into Python
diveintopython.org › home › learn python programming › regex in python
RegEx in Python: Match and Replace Basics with Examples
May 3, 2024 - The re module in Python provides a method called sub() which stands for substitute. It's the cornerstone for performing python replaceall regex operations. The syntax is straightforward: re.sub(pattern, replacement, string).
🌐
Codedamn
codedamn.com › news › python
Python replace regex for searching and replacing strings
July 1, 2023 - This can be done using the following line of code: ... One common use of regex is to find and replace certain parts of a string. This is accomplished using the re.sub() function in Python's re module.
🌐
Real Python
realpython.com › replace-string-python
How to Replace a String in Python – Real Python
October 22, 2025 - 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 Python's re module.
🌐
GeeksforGeeks
geeksforgeeks.org › python › python-substituting-patterns-in-text-using-regex
Python - Substituting patterns in text using regex - GeeksforGeeks
July 12, 2025 - # Python implementation of substituting a # specific text pattern in a string using regex # importing regex module import re # Function to perform # operations on the strings def substitutor(): # a string variable sentence1 = "It is raining outside." # replacing text 'raining' in the string # variable sentence1 with 'sunny' thus # passing first parameter as raining # second as sunny, third as the # variable name in which string is stored # and printing the modified string print(re.sub(r"raining", "sunny", sentence1)) # a string variable sentence2 = "Thank you very very much."
🌐
Delft Stack
delftstack.com › home › howto › python › python regex replace
Regex replace() Method in Python | Delft Stack
March 11, 2025 - In the world of programming, text manipulation is a common task, and Python offers a powerful tool for this purpose through its re module. One of the most essential functions in this module is the re.sub() method, which allows you to search ...
🌐
Pandas
pandas.pydata.org › docs › reference › api › pandas.Series.str.replace.html
pandas.Series.str.replace — pandas 3.0.5 documentation
Method to replace occurrences of a substring with another substring. ... Extract substrings using a regular expression. ... Find all occurrences of a pattern or regex in each string.
🌐
YouTube
youtube.com › automate with rakesh
#78 How to Search and Replace Strings in Python using Regex - YouTube
Learn how to use the regex in python to search and replace strings.Important Links:🔥 Visit Channel : https://www.youtube.com/c/AutomatewithRakesh🔥 To Su...
Published: July 16, 2022
Views: 3K
🌐
Leapcell
leapcell.io › blog › how-to-use-python-regex-for-string-replacement
How to Use Python Regex for String Replacement | Leapcell
July 25, 2025 - To use regex in Python, first import the built-in re module: ... The main function used for regex replacement is re.sub(pattern, repl, string).
🌐
JanBask Training
janbasktraining.com › community › python-python › python-replace-regex
python .replace() regex | JanBask Training Community
May 7, 2025 - `str.replace()` performs a direct substring match. It does not interpret patterns, special characters, or regex tokens. ... Nothing changes because `d+` is treated as a literal string, not a pattern.