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

How does [\d+] regular expression work in Python?


The following code shows what the regular expression [\d+] does on the given string

[\d+] regular expression refers to one digit (0-9) or + character 

Example

import re
result = re.findall(r'[\d+]', 'Taran123tula+456')
print result

output

['1', '2', '3', '+', '4', '5', '6']