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

Updated on: 19-Feb-2020

131 Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements