1
python re.sub group: numéro après \ number
Comment puis-je remplacer foobarpar foo123bar? Cela ne fonctionne pas: >>> re.sub(r'(foo)', r'\1123', 'foobar') 'J3bar' Cela marche: >>> re.sub(r'(foo)', r'\1hi', 'foobar') 'foohibar' Je pense que c'est un problème courant lorsqu'on a quelque chose comme \number. Quelqu'un peut-il me donner un indice sur la façon de gérer cela?