python - re.sub issue when using group with \number -
i'm trying use regexp arrange text, re.sub
.
let's it's csv file have clean make totally csv.
i replaced \t \n doing :
t = t.replace("\n", "\t")
... , works fine. after that, need \t \n, each of csv lines. use expression :
t = re.sub("\t(\d*?);", "\n\1;", t, re.u)
the problem works... partially. \n added properly, instead of being followed matching group, followed ^a (according vim)
i tried regexp using re.findall
, works juste fine... wrong according ?
my csv lines supposed :
number;text;text;...;...;\n
thanks !
your \1
interpreted ascii character 1. try using \\1
or r"\n\1;"
.
Comments
Post a Comment