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

How to match a single character in python using Regular Expression?


We use the following code to match and print any single character in the given string using python regular expression.this matches any single character in the given string

Example

import re
foo = 'https://www/twitter/index.php 403'
result = re.findall(r'.', foo)
print result

Output

This gives the output

['h', 't', 't', 'p', 's', ':', '/', '/', 'w', 'w', 'w', '/', 't', 'w', 'i',
 't', 't', 'e', 'r', '/', 'i', 'n', 'd', 'e', 'x', '.', 'p', 'h', 'p', ' ',
'4', '0', '3']