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



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']

Advertisements