.replace() regex in Python

0 votes
I am using the </html> tag to grab everything and delete it. But the code doesn't seem to work. Can anyone tell if .replace() does not support regex?

z.write(article.replace('</html>.+', '</html>'))
Nov 26, 2018 in Python by ana1504.k
• 5,910 points

1 answer to this question.

Your answer

Your name to display (optional):
Privacy: Your email address will only be used for sending these notifications.
0 votes

No,  .replace() does not support regex. Regular expressions in Python are handled by the re module.

such as :

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

answered Nov 26, 2018 by SDeb
• 9,380 points

Related Questions In Python

0 votes
1 answer

How to use string.replace() in python 3.x

replace() is a method of <class 'str'> ...READ MORE

answered Aug 3, 2018 in Python by Priyaj
• 56,100 points
0 votes
1 answer

How to replace values with None in Pandas data frame in Python?

Actually in later versions of pandas this ...READ MORE

answered Aug 30, 2018 in Python by Priyaj
• 56,100 points
0 votes
1 answer

Replace NaN in rolling mean in python

Try this: In [92]: ts.rolling(window=2, min_periods=1).mean() Out[92]: ...READ MORE

answered Sep 27, 2018 in Python by Priyaj
• 56,100 points
+3 votes
7 answers

How can I rename a file in Python?

yes, you can use "os.rename" for that. ...READ MORE

answered Mar 31, 2018 in Python by DareDev
• 6,520 points
0 votes
1 answer

how can i count the items in a list?

suppose you have a list a = [0,1,2,3,4,5,6,7,8,9,10] now ...READ MORE

answered May 2 in Python by Mohammad
• 920 points
0 votes
1 answer

Python Regex Search And Replace

You need not use a regex. Your ...READ MORE

answered 4 hours ago in Python by SDeb
• 9,380 points
0 votes
1 answer

Indentation of Python in Notepad++

To indent the block, select the entire ...READ MORE

answered Sep 18, 2018 in Python by SDeb
• 9,380 points

© 2018 Brain4ce Education Solutions Pvt. Ltd. All rights Reserved.
"PMP®","PMI®", "PMI-ACP®" and "PMBOK®" are registered marks of the Project Management Institute, Inc. MongoDB®, Mongo and the leaf logo are the registered trademarks of MongoDB, Inc.