fork(1) download
  1. import re
  2. string = "one,two,three,"
  3. res = ",".join(["Aa" if x else "" for x in string.split(",")]) # non-regex way
  4. print(res)
  5. print(re.sub(r'.*?(?=,)',r'aA', string)) #regex: fixed version
  6. print(re.sub(r'.*?(,+)',r'aA\1', string)) #regex: capturing and backreferences
  7. print(re.sub(r'[a-z]+',r'aA', string, flags=re.I)) # a very simple, shortest possible working regex
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
Aa,Aa,Aa,
aA,aA,aA,
aA,aA,aA,
aA,aA,aA,