fork(3) download
  1. import re
  2.  
  3. s = "aba\naaa\naba\n\naba"
  4. rx = r'(?:{0}(?:\n|$))+|(?:\n|^){0}'.format(r'[^b\n]*b.*')
  5. print(rx)
  6. print( re.sub(rx, '', s).replace('\n','\\n') )
  7.  
Success #stdin #stdout 0.01s 27744KB
stdin
Standard input is empty
stdout
(?:[^b\n]*b.*(?:\n|$))+|(?:\n|^)[^b\n]*b.*
aaa\n