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

PythonServer Side ProgrammingProgramming

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']
raja
Published on 02-Jan-2018 10:34:23
Advertisements