s/ (?>[^>]) ^>>> (?= [^\n]*\n # <-- removed < and added first \n (?!^>>[^>]) # <-- moved into (?=...) ) /PYTHON_PROMPT/xmg;