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

PythonServer Side ProgrammingProgramming

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']
raja
Published on 02-Jan-2018 09:51:49
Advertisements