fork(1) download
  1. import re
  2. pat = r"\b(see|under|in|of|with|this)\b( *.{0,4})(item)"
  3. s = "i have many roof item in the repeat item of the item inthe item downunder. with any item"
  4. res = re.sub(pat, r"\1\2replaced_item", s)
  5. print(res)
Success #stdin #stdout 0s 23304KB
stdin
Standard input is empty
stdout
i have many roof item in the repeat item of the replaced_item inthe item downunder. with any replaced_item