How do i match just spaces and newlines with Python regex?

PythonServer Side ProgrammingProgramming

The following matches and prints just spaces and newlines in the given string using Python regex

Example

import re
foo = ' I find
  Tutorialspoint
  useful'
result = re.findall(r'\s+', foo)
print result

Output

This gives the output

[' ', ' ', ' \n ', ' \n ']
raja
Published on 10-Jan-2018 07:47:19
Advertisements