相关疑难解决方法(0)

如何在string.replace中输入正则表达式?

我需要一些关于声明正则表达式的帮助.我的输入如下:

this is a paragraph with<[1> in between</[1> and then there are cases ... where the<[99> number ranges from 1-100</[99>. 
and there are many other lines in the txt files
with<[3> such tags </[3>
Run Code Online (Sandbox Code Playgroud)

所需的输出是:

this is a paragraph with in between and then there are cases ... where the number ranges from 1-100. 
and there are many other lines in the txt files
with such tags
Run Code Online (Sandbox Code Playgroud)

我试过这个:

#!/usr/bin/python
import os, sys, re, glob
for infile in glob.glob(os.path.join(os.getcwd(), '*.txt')):
    for …
Run Code Online (Sandbox Code Playgroud)

python regex string replace

272
推荐指数
6
解决办法
29万
查看次数

标签 统计

python ×1

regex ×1

replace ×1

string ×1