fork download
  1. import re
  2. rx = r"X.*?C.*?(B|Y|A)"
  3. s = "X Hello C there. I am B a String. Y I C am a A good string."
  4. print(re.sub(rx, r"\1", s))
  5.  
  6.  
Success #stdin #stdout 0s 9024KB
stdin
Standard input is empty
stdout
B a String. Y I C am a A good string.