Computer >> Computer tutorials >  >> Programming >> Python

How to match any non-digit character in Python using Regular Expression?


The following code matches and prints all non-digit characters in the given string using python regex as follows.

Example

import re
foo = 'Mo4zam5Bi6QuE7'
match = re.findall(r'\D', foo)
print match

Output

This gives the output

['M', 'o', 'z', 'a', 'm', 'B', 'i', 'Q', 'u', 'E']