fork download
  1. import re
  2. sentence = 'hello, join this meeting heere using thiis lllink'
  3. keepWord = ['hello','meeting']
  4. new_sentence = re.sub(fr"\b(?:{'|'.join(keepWord)})\b|([^\W\d_])\1+", lambda x: x.group(1) or x.group(), sentence)
  5. print(new_sentence)
Success #stdin #stdout 0.02s 9548KB
stdin
Standard input is empty
stdout
hello, join this meeting here using this link