如何在单个lin中生成不同的多个正则表达式语句

2024-10-04 01:24:16 发布

您现在位置:Python中文网/ 问答频道 /正文

我试着在一行中做一些不同的正则表达式语句。。。语法应该是更多的re.sub(r''.format(x1,y1), ''.format(x2,y2), a, 1),其中x1应该代替x2,y1应该代替单个字符串中的y2

import re
a = 'browhereareyou'
def sub(p, m):
    return re.sub(p, m, a, 1)
# no idea what next though i'm sure my func is not okay as well

Tags: no字符串importreformatreturndef语法