How to match tab and newline but not space using Python regular expression?


The following code matches tab and newline but not space from given string using regex.

Example

import re
print re.findall(r"[\n\t]","""I find
    Tutorialspoint useful""")

Output

This gives the output

['\n']

Updated on: 19-Dec-2019

1K+ Views

Kickstart Your Career

Get certified by completing the course

Get Started
Advertisements