像这样
text = " \t hello there\n \t how are you?\n \t HHHH"
hello there
how are you?
HHHH
我可以通过正则表达式获取公共前缀子字符串吗?
我试着
In [36]: re.findall(r"(?m)(?:(^[ \t]+).+[\n\r]+\1)", " \t hello there\n \t how are you?\n \t HHHH")
Out[36]: [' \t ']
但显然,公共前缀子字符串是 ' \t '
我想用于dedent
像 python textwrap 模块这样的函数。