How to split on successions of newline characters using Python regular expression?

PythonServer Side ProgrammingProgramming

The following code splits on successions of newline characters in the following string using Python regex

Example

import re
s = """I find
 Tutorialspoint
  useful"""
print re.split(r"[\n]", s)

Output

This gives the output

['I find', '    Tutorialspoint', '     useful']
raja
Published on 10-Jan-2018 10:59:04
Advertisements