2
在Perl中,我會寫:在Python中,我該如何做一個字符串替換和回收替換的子字符串?
$x = "abbbc";
$x =~ s/(b+)/z/;
print "Replaced $1 and ended up with $x\n";
# "Replaced bbb and ended up with azc"
如何在Python做到這一點 - 做一個正則表達式的字符串替換和記錄一下她已經獲得更換?