fork download
  1. import re
  2.  
  3. strings = [
  4. "asd-wqe ffvrf",
  5. "asd-ss sd",
  6. "a-word",
  7. "a-verylongword",
  8. "an-extremelyverylongword"
  9. ]
  10. pattern = r"(?<=-)\w+"
  11. for s in strings:
  12. print(re.sub(pattern, lambda x: len(x.group()) * "*", s))
Success #stdin #stdout 0.03s 9492KB
stdin
Standard input is empty
stdout
asd-*** ffvrf
asd-** sd
a-****
a-************
an-*********************