fork download
  1. import re
  2.  
  3. input_var = """THE SONNETS
  4.  
  5. 1
  6.  
  7. From fairest creatures we desire increase,
  8. That thereby beauty’s rose might never die,
  9. But as the riper should by time decease,
  10. His
  11.  
  12. she hies, 1189
  13. And yokes her silver doves; by whose swift aid
  14. Their mistress mounted through the empty skies,
  15. In her light chariot quickly is convey’d; 1192
  16. Holding their course to Paphos, where their queen
  17. Means to immure herself and not be seen."""
  18.  
  19. pattern = {r'\s{3,}\d+\n' : '',
  20. r'\n' : ' '}
  21. output_var = input_var
  22. for reg, repl in pattern.items():
  23. output_var = re.sub(reg, repl, output_var)
  24.  
  25. print(output_var)
Success #stdin #stdout 0.02s 9548KB
stdin
Standard input is empty
stdout
THE SONNETS From fairest creatures we desire increase, That thereby beauty’s rose might never die, But as the riper should by time decease, His  she hies,And yokes her silver doves; by whose swift aid Their mistress mounted through the empty skies, In her light chariot quickly is convey’d;  Holding their course to Paphos, where their queen   Means to immure herself and not be seen.