Oh, I've missed slice(0, -1). What do you think about movin regexp+replace back? I think this func would be more obvious then.