- Trending Categories
- Data Structure
- Operating System
- C Programming
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
What Python regular expression can be used in place of string.replace?
The following code replaces all the characters from given string with ''
import re line = 'this is a text with<[2> in between</[3> and then there are instances ... where the<[43> number ranges from 0-99</[76>.\ and there are many other lines in the text files \ with<[7> such tags </[8>' line = re.sub(r"</?\[\d+>", "", line) print line
This gives the output
this is a text with in between and then there are instances ... where the number ranges from 0-99.and there are many other lines in the text files with such tags
- What are repeating character classes used in Python regular expression?
- What is Raw String Notation in Python regular expression?
- What are metacharacters inside character classes used in Python regular expression?
- What are character classes or character sets used in Python regular expression?
- What is a regular expression in Python?
- How can MySQL REPLACE() function be used with WHERE clause?
- What names can be used in plt.cm.get_cmap?
- Regular Expression Modifiers in Python
- Regular Expression Patterns in Python
- Regular Expression Examples in Python
- Regular Expression Matching in Python
- What are regular expression repetition cases in Python?
- How an enumeration value in MySQL can be used in an expression?
- What is regular expression in Java?
- Regular Expression in Python with Examples?