Get the common prefix substring through Regex
Posted
by
Dreampuf
on Stack Overflow
See other posts from Stack Overflow
or by Dreampuf
Published on 2012-11-03T05:25:49Z
Indexed on
2012/11/03
11:01 UTC
Read the original article
Hit count: 204
like this
text = " \t hello there\n \t how are you?\n \t HHHH"
hello there
how are you?
HHHH
Could I get the common prefix substring through regex?
I try to
In [36]: re.findall(r"(?m)(?:(^[ \t]+).+[\n\r]+\1)", " \t hello there\n \t how are you?\n \t HHHH")
Out[36]: [' \t ']
But apparently that common prefix substring is ' \t '
I want use for dedent
function like python textwrap module.
© Stack Overflow or respective owner