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

Popular posts from this blog

windows - Why does Vista not allow creation of shortcuts to "Programs" on a NonAdmin account? Not supposed to install apps from NonAdmin account? -

c++ - How do I get a multi line tooltip in MFC -

unit testing - How to mock PreferenceManager in Android? -