fork(1) download
  1. import re
  2. r = re.compile(r"^(text[ ]*=[ ]*')((?:[^',]*(,?)[^']*)?[^']*)(')")
  3. print(r.sub(r"\1\2\3d\4", "text = 'a,b,c'"))
  4. print(r.sub(r"\1\2\3d\4", "text = ''"))
Success #stdin #stdout 0.01s 8968KB
stdin
Standard input is empty
stdout
text = 'a,b,c,d'
text = 'd'