fork(1) download
  1. import re
  2. str1 = "ur a sh * tty comment ."
  3. #print( re.sub(r'\S+ +\* +\S+', lambda x: x.group().replace(' ', '*') , str1) )
  4. nw = r"[]*!@#$%^&()[{};:,./<>?\\|`~=_+-]"
  5. print( re.sub(rf'(\S) {nw} (\S)', r'\1***\2' , str1) )
Success #stdin #stdout 0.02s 9624KB
stdin
Standard input is empty
stdout
ur a sh***tty comment .