fork download
  1. import re
  2.  
  3. pattern = r"#/\*(?!.*\*/).*(?:\n(?!.*\*/).*)*\n.*\*/\n*(?!\S)"
  4.  
  5.  
  6. s = ("1.2.3.4/24#/* 208-01 | 208-02 | \n"
  7. " ** | test |\n"
  8. " ** test2 */\n\n"
  9. "5.6.7.8/27#/* just a comment */\n"
  10. "9.10.11.12/32#/* comment\n"
  11. " ** part of comment above */\n"
  12. "11.23.13.14/32#/* comment */")
  13. s = re.sub(pattern, lambda x: re.sub(r"\n", "", x.group()), s)
  14. print(s)
Success #stdin #stdout 0.03s 9428KB
stdin
Standard input is empty
stdout
1.2.3.4/24#/* 208-01 | 208-02 |                          ** | test |                         ** test2 */
5.6.7.8/27#/* just a comment */
9.10.11.12/32#/* comment                         ** part of comment above */
11.23.13.14/32#/* comment */