什么Python正则表达式可以替换字符串.replace?

什么Python正则表达式可以替换字符串.replace?

以下代码将给定字符串中的所有字符替换为”。

阅读更多:Python 教程

示例

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

Python教程

Java教程

Web教程

数据库教程

图形图像教程

大数据教程

开发工具教程

计算机教程